ASP
  Home arrow ASP arrow Page 2 - Maintaining Session State With ASP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Maintaining Session State With ASP
By: Himanshu Khatri
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 27
    2002-08-30

    Table of Contents:
  • Maintaining Session State With ASP
  • The Session Object
  • The Application Object
  • The Global.asa File
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    Syntax:

    Session.collection|property|method

    Properties:
    • 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.
    Methods:
    • 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.
    Example:

    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

    More ASP Articles
    More By Himanshu Khatri


     

    ASP ARTICLES

    - 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...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway