Global.asa is a text file found in your home directory (/Global.asa). Lou shows the basic extructure a Global.asa file.
Global.asa
<script language= "VBScript" runat= "Server" >
Sub Application_OnStart
........
End Sub
Sub Application_OnEnd
End Sub
Sub Session_OnStart
........
End Sub
Sub Session_OnEnd
........
End Sub
</SCRIPT>
The file will be activated in this case:
When the first visitor visits our web page
When the new session starts.
In both cases, we may have identified a series of activities that are in the execution of the aforementioned document.
Application_OnStart
This was initiated prior to the implementation of the first session.
Application_OnEnd
This is the execution of the application when it has been completed.
Session_OnStart
This is done when the server creates a new meeting (when a new client acccesses our server).
Session_OnEnd
This is performed when a certain amount of time is discarded after the client and server are not contacted (Normaly 20 minutes later, or from the previous request from a particular client, the server will consider that he will not come back, and therefore will delete all relevant information about the meeting).
You can try a very simple example:
Active user Counters
Just copy the Code table to a text file and save it in a Web site ("/Global.asa") in the home directory.
<script language= "VBScript" runat= "Server" >
Sub Application_OnStart
Application ("Activevisitors") =0
End Sub
Sub Application_OnEnd
End Sub
Sub Session_OnStart
Application.Lock
Application ("Activevisitors") =application ("Activevisitors") +1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application ("Activevisitors") =application ("Activevisitors")-1
Application.UnLock
End Sub
</SCRIPT>
The first visitors to our web page, Global.asa will be executed, so application ("Activevisitors") on line Line 4 will gain value equal to "0". Immediately (as a new meeting has begun), on line Line 12, Application ("Activevisitors") will increase by 1. Whenever a new visitor enters our page application ("Activevisitors") will add one, the same, after each session, this parameter will be reduced by one (line 18).
In case we want to show the number of visitors on our web page, we must use this code:
<% =application ("activevisitors")%>