Home arrow ASP arrow Page 2 - Maintaining Session State With ASP

Maintaining Session State With ASP

Sessions and cookies can be used to persist visitor information. In this article Himanshu shows us how to main session state with ASP using a combination of cookies, sessions and the global.asa file.

Author Info:
By: Himanshu Khatri
Rating: 5 stars5 stars5 stars5 stars5 stars / 82
August 30, 2002
  1. · Maintaining Session State With ASP
  2. · The Session Object
  3. · The Application Object
  4. · The Global.asa File
  5. · Conclusion

print this article

Maintaining Session State With ASP - The Session Object
(Page 2 of 5 )

The session object is used to store variables for each specific visitor to your web site. These variables could represent anything from how many pages the user has viewed to their login details. A session is defined as the time from when the user visits your site to the time when he leaves session variables die after a visitor closes their web browser (i.e. they are not persistent).

Variables stored in the session object are available to all ASP pages on that particular web site. Common information stored in session variables includes name, id, and personalization preferences. The server creates a new session object for each new user and destroys the session object when the session expires.

A session object is specific for every user and varies from user to user. IIS will maintain these variables when the client moves across pages within the site.



  • SessionID: A long number that returns the session identifier for this client.
  • Timeout: An integer that specifies a timeout period in minutes. If the client doesn't refresh or request any page from your site within this timeout period then the server ends the current session. If you do not specify any timeout period then the default timeout period of 20 minutes is used.
  • Abandon: Destroys the current session object and releases its resources, meaning that if the client requests any page from your site after the Session.Abandon method has been called then a new session will be started.
  • Session_OnEnd: This event occurs when the session is abandoned or times out for a specific user.
  • Session_OnStart: Occurs when a new session is started. All ASP objects are available for you to use. You can define your session wide variables here.

You can store any value you like in the session object. Information stored in the session object is available for the entire session and has "session scope". The following script demonstrates how two types of variables are stored:

Session("username") = "Janine"
Session("age") = 42

blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials