Working with Session Variables and Cookies

The way to share session variables between two runs of an application is to persist the session variable by means of HTTP cookies. Genero must provide a way to set and get session variables to and from cookies.

Figure 1. Create, Set, and Get Session Variables and HTTP Cookies


Session variables and cookies diagram

A session variable or cookie can be created and updated in the following ways:

Session Variable / HTTP Cookie synchronization

Every session variable may not need to be put into an HTTP cookie. Conversely, every HTTP cookie value need not be put into a session variable.

The idea is to tag each session variable that has to be set into a cookie. The snippet-based rendering engine (with the GAS) would be in charge of maintaining the cookies/session variables synchronization. On incoming HTTP requests, the engine would update corresponding session variables; on outgoing HTTP responses, the engine would set changed cookies. Between the request and the response, the 4GL developer can update session variables. Therefore, updating an HTTP cookie is indirectly done by updating its session variables.