Name

setsession — set a session variable

Synopsis

void setsession( sessionvar,  
  value);  
string   sessionvar ;
string   value;

Description

Assigns the string value to the session variable named by sessionvar. Session variables are persistent between page accesses and can later be read by session().

Example 50. setsession 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”.