Uniface Cookies

Uniface provides a cookie mechanism for state management. It also provides predefined ProcScript in the preActivate and postActivate triggers so that the state of component variables are maintained automatically

On the browser side, a cookie or the ID of a cookie is kept in memory. By default, a cookie expires when the browser is closed, but if an expiration time is specified, it is written to disk. To use cookies, the browser client machine must allow cookies.

Uniface supports single unnamed cookies and multiple named cookies. You can use $webinfo to set the properties of a cookie and write state information to a cookie.

Some Web servers have limitations on the size of a cookie and some browsers do not accept cookies. In this case, consider using URL-based state management.

Single Cookies

If you only need a single cookie, you can use $webinfo("USERCONTEXT") to read and write the cookie.

Multiple Cookies

To use multiple cookies, use $webinfo("COOKIESIN") and $webinfo("COOKIESOUT") to read and write cookies. For example, you can create a cookie to store some preferences for the application that remain stored on the client side for an unlimited time. In another cookie, you can store some retrieve profiles that the user uses in this session (expires at session end).

In the preActivate and postActivate trigger, Uniface generates some predefined ProcScript for setting and retrieving the values of component variables. You can modify the code to add the desired data in the cookie, or to build up multiple cookies.

Related Topics