SunQuest
 
       ASP
  Home arrow ASP arrow Page 3 - 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  
Actuate Whitepapers 
Moblin 
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Maintaining Session State With ASP - The Application Object


    (Page 3 of 5 )

    The Application object is used to store variables and to access variables from any page. All users share one Application object.

    All variables created within the application object have application level scope, meaning that they are accessible to all users who visit your site. All ASP pages in a virtual directory and its subdirectories come under the application scope, so more than one user shares application level variables at any time.

    Syntax:

    Application.method

    Methods:
    • Lock: Prevents other users from changing the application objects properties
    • Unlock: Allows other users to change the application objects properties
    Events:
    • Application_OnEnd: This routine is called when all user sessions expire and the application quits. This event lives in the global.asa file, which we will look at shortly.
    • Application_OnStart: This routine is called when the application object is first references. This event lives in the global.asa file as well.

    Example:

    This example uses an application variable to determine the uptime of the server. To achieve this we simply add an application variable to the OnStart event in the global.asa file, which needs to exist in the root directory of your web server:

    <script language="VBScript" runat="Server">

    Sub Application_OnStart
    Application("startTime") = Now
    End Sub

    </script>


    The following VBScript will display the uptime:

    <% @ language="vbscript" %>
    <% Option Explicit %>
    <%

    Dim days, hours, minutes, seconds, startTime, runTime

    ' Read the start time from the
    ' Application variable
    startTime = CDate(Application("startTime"))

    ' Take the difference
    runTime = CDate(Now - startTime)

    ' Calculate the time components
    If DateDiff("d", startTime, Now) = 0 Then
    days = 0
    Else
    days = Day(runTime)
    End If
    hours = Hour(runTime)
    minutes = Minute(runTime)
    seconds = Second(runTime)

    ' Display the uptime
    Response.Write "Uptime: " & days & " days(s), "
    Response.Write hours & " hour(s), "
    Response.Write minutes & " minute(s), and "
    Response.Write seconds & " second(s)"

    %>

    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 6 hosted by Hostway