Session variables provide a mechanism through which user information can be stored and accessed for use by web applications. Typically, session variables store information (usually form or URL parameters submitted by users) and make that information available to all of the applications pages for the duration of the users visit. For example, when users log on to a web portal that provides access to e-mail, stock quotes, weather reports, and daily news, the web application stores the login information in a session variable that identifies the user throughout the sites pages. This allows the user to see only the types of content they have selected as they navigate through the site. Session variables can also provide a safety mechanism in the form of a time-out that terminates the users session if the account remains inactive for too long a period of time. This also frees server memory and processing resources if the user forgets to log off a website.
Session variables are commonly used to store user display preferences, answers to multipart questionnaires, items chosen for purchase in so-called "shopping cart" applications, and running score tallies for online games.
This section covers the following topics: