The OnStart event occurs before the start of any new session by a user (i.e., before the Application object is first referenced). The signal of this event will run a handler script in the Global.asa file, if the script exist.
The Application_OnStart event occurs before the beginning of any user session. The only built-in ASP objects available from within the OnStart event handler are Server and Application.
The Application_OnStart event is simply a subroutine with a reserved name that is placed within the Global.asa file.
It contains any script that you wish to run before the first user session.
For example, you could use the Session.Timeout property
to automatically end an idle user session after 10 minutes.
Note that you must declare the scripting language used to code the event script on the first line
of the Global.asa file.
-------------------Global.asa--------------------------
<script Language="VBScript" RUNAT=Server>
Sub Application_OnEnd()
End Sub
Sub Application_OnStart()
Application("NumSession") = 0
Application("NumVisited") = 0
Session.Timeout = 10
End Sub
Sub Session_OnEnd()
Application("NumSession") = Application("NumSession") - 1
End Sub
Sub Session_OnStart()
Application("NumSession") = Application("NumSession") + 1
Application("NumVisited") = Application("NumVisited") + 1
End Sub
</script>
-------------------File1.asp----------------------------
Response.Write "You are " & Application("NumSession") & " of " & Application("NumVisited") & " users."
You are 1 of 1 users.