session — read a session variable


string session( sessionvar);  
string   sessionvar ;


Returns the value of the session variable sessionvar. If no such session variable exists then "" is returned.

Example 48. session Example

// Get the next counter value.  The counter starts at zero and is increased
// each time the page is accessed.  Note that the first time the page is
// accesses the session variable "next-counter-value" won't exist so
// session("next-counter-value") will return "", but (int)"" is defined to be
// zero so it all works as expected.
int counter = (int)session("next-counter-value");
setsession("next-counter-value", (string)(counter + 1));

See Also

Session variables and their use are explained in the section called “Session Management”.