391 users using DBSP now!
home -> documentation -> language reference -> The SESSION object


Description

Each user that has access to a DBSP site implicitly generates a SESSION object. This object is responsible for storing particular information relative to the user like the IP address, browser type, timestamp of the first session request, timestamp of the last session request, etc.

Note: the session object exists even when an authentication has not been made.


Default values for every session

These values can be retrieved for any session:

SESSIONID This is a random string that uniquely identifies a session over the time.
BROWSER Retrieves the browser's identification name (User-Agent value) included in the request header.
IPADDRESS Retrieves the IP address informed in the request header.
LASTREQUESTTIME Retrieves the time of the last request the user made.


These variables contain values only if a successful login has been made:

LOGINTIME Retrieves the time at which the user logs into the application.
LOGGEDTIME Retrieves the time that the user has been active on the application.
INACTIVETIME Retrieves the time passed now and the last request made by the user.

For example you can build an access log using a query like this one:

INSERT INTO ACCESSLOG VALUES (<#SESSION.IPADDRESS>, <#BROWSER/>)

Appending values to the session object

Once a DBSP site has been defined, the values of the columns selected in the LOGIN query will be appended to the session object.

Note: The values stored in the session object can not be changed. These values are read only for security reasons.

For example: suppose that the LOGIN query looks like this:

SELECT USERID, USERNAME, DEPARTMENTID FROM USERS
WHERE USERNAME= '<#USERNAME/>' AND
PASSWORD = '<#PASSWORD/>'

After the user has logged in successfully the values for USERID, USERNAME and DEPARTMENTID will be part of the session object. For use this values in any page while the session remains live, we simply write for example:


<H1>Welcome: <#SESSION.USERNAME/> </h1>

Or we can use them inside SQL sentences

<H1>Welcome: <#SESSION.USERNAME/> </h1>