ASP  «Prev  

Summary of the Session object in Classic ASP


Session.[collection|property|method]|("variable")
Collections
Contents All the Session variables (and their values) are stored in the Contents collection.
StaticObjects All the objects created with the <OBJECT> tag, but not those created with the CreateObject() method of the Server object.
Properties
CodePage The code page determines how character codes are mapped to display characters.
LCID A standard identifier that determines which system-defined locale should be used.
SessionID The Session ID for a particular user/session.
TimeOut How long (in minutes) should ASP wait for activity before ending this session and clearing its session variables?
Events
Session_OnEnd A procedure that runs when a session ends. The code for this procedure (if one is used) is stored in the Global.asa file.
Session_OnStart A procedure that runs when a session begins. The code for this procedure is stored in the Global.asa file.
Methods
Abandon() Terminate this session and everything (in particular, all the Session variables) that goes along with it. If the session times out, this happens automatically, but you can force it with the Abandon() method.

Session object: Stores persistant information for each user session.
Warning: Using the Session object requires that sessions be enabled for the application. Otherwise, an error will occur.
Warning: User sessions require the client to support and accept cookies in order to function properly. It is a good idea to configure your server to support P3P [ http://www.w3.org/P3P/] , in order to support newer browsers with more paranoid privacy settings.
Session.Abandon method: Closes the session, freeing up all associated resources.
Usage: Session.Abandon
Details: Always abandon the session once you know the user has finished with the application. Providing a link to a simple logoff page is one way to accomplish this.
<%
Session.Abandon
Response.Redirect "/" ' send user to the site's home page
%>
Example Logoff.asp