400 users using DBSP now!
home -> documentation -> environment guide -> Extending scope of the variables


Sometimes is necessary to display a value in several pages of the system like the name of the user. Other times we want to remember the identity of the user in order to display his site preferences correctly and bring him a better browsing experience. We can complete this tasks using the SETCOOKIE tag.

The SETCOOKIE tag is used to extend the life of some value stored in a variable as long as the session reamains active (the browser remains open). From now on, we will refer to these variables as session variables.

Note: All the sessions variables will persist until the browser window is closed.

Consider that the next snippet is inserted in your currently displayed page:

.
.
.
<#SETCOOKIE NAME="businessunit" VALUE="Marketing Department"/>
.
.
.

We could use this value in any other following page, by simply inserting the name of the variable. For example, consider the following snippet:

.
.
.
<p><b><#BUSINESSUNIT/></b></p>
.
.
.

After the document is interpreted by the DBSP engine, this variable will be replaced by his value, obtaining something like this:

.
.
.
<p><b>Marketing Department</b></p>
.
.
.

 

Note: All the variables are case insensitive. This means that you could actually use <#BUSINESSUNIT/> or <#businessunit/> and the final result will be the same.

 

Extending the life of the variables: Setting an expiration time

You can make a variable persistent between multiple sessions, if you define an expiration time. This expiration time is the time in days that the cookie will remain live on the client browser. Consider the next examples:

<#SETCOOKIE NAME="USERID" VALUE="15" EXPIRES="10.5"/>

This code indicates to the DBSP Engine that the USERID variable will remain active for 10 days and 12 hours after the page was loaded. After these period of time the value will desapear from the browser. The variable will be crypted with a 128 bits algorithm and then stored on the user browser as a cookie. If you want to know more the security features of DBSP, go to the Section 9.2: DBSP Security features.


Related topics

If you want to know all the features of the SETCOOKIE tag, click on the following link:
DBSP language reference: SETCOOKIE tag

If your want to know how to delete variables from the session, click on the following link:
Deleting variables: the KILLCOOKIE tag

If you want to learn more about the security issues of DBSP, click on the following link:
DBSP documentation 9.2 : DBSP Security features
.

Previous | Next