Session Variables

Overview

You can use the Session object to store variables that will remain available for the length of the session, and, therefore, have session scope. For instance, if you have created an online shopping application, you could define Session object variables that allow you to track how much merchandise the shopper has purchased or how much money is owed.

Code Tour

This example uses the variable SessionCount to store the number of times you have clicked the Click here to visit it again link.

Remarks

If you visit this sample several times, then visit other sections of this documentation before visiting this sample again, the count will pick up where you left off. This is because the server's Session object that is associated with your particular Web session will not be destroyed until your session has timed out.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\applications\Session_VBScript.asp and ...\asp\applications\Session_JScript.asp.