(1 ratings)   
By: Learnfobia
The global.asa file is a special file that handles session and application events. This file must be spelled exactly as it is here on this page and it must be located in your websites root driectory. This is a very useful file and can be used to...
Added: 25 June 2008    Views: 1259  
PathComputers    Programming    Asp
Keywords: computers   programming   language   asp   database   functions   code   coder  
Do you like this tutorial? Now you can support our team to add more :     
 
 
 

For example, we use the global.asa file on this website to display the number of Active Users on our site. Rather than inputting data into a database and keeping a stored record of it, our global.asa file acts as a monitor of how many users are visiting any page our website. There are no records stored in any database or text file, the information just flows in and out. Take a look at the code below we use to do this:

SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
' Set our user count to 0 when we start the server
Application("ActiveUsers") = 0
End Sub

Sub Session_OnStart
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 20
' Set a Session Start Time
' This is only important to assure we start a session
Session("Start") = Now
' Increase the active visitors count when we start the session
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub Sub Session_OnEnd

' Decrease the active visitors count when the session ends.
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
--end script here

What the global.asa file does is create a session for each new user that is actively surfing any part of our website. Then, the session will time out or end either when the user leaves our website or at the default setting of 20 minutes.

There are several other things you can use the global.asa file for, but this tutorial was just intended to show you what makes this file special and to give you an idea of what it is used for.

About the Author :
Learnfobia
GLOBAL.ASA IN ASP
Articles and Tutorials Directory by www.learnfobia.com
 Rate this tutorial : Rate 1Rate 2Rate 3Rate 4Rate 5
  |    Add to Favorites
  |    Send to Friend
  |    Print
Comments