| Active Server Pages: Global.asa |
| global.asa |
| <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
Sub Application_OnEnd
Sub Session_OnStart
Sub Session_OnEnd
</SCRIPT> |
This file will be activated in this cases:
Lets try a very simple example:
Just copy the code in the table to a text file and save it in the main
directory of your site ("/global.asa").
| global.asa | |
| <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
Sub Application_OnEnd
Sub Session_OnStart
Sub Session_OnEnd
</SCRIPT> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
The first time a visitor gets to our pages, global.asa will be executed, and consequently, application("activevisitors") in line 4 will get a value equal to "0". Immediately (as a new session has started), in line 12, application("activevisitors") will be increased by one. Each time a new visitor gets to our pages application("activevisitors") will be increased by one, and identically, each time a session is finished, this parameter will be reduce by one (line 18).
In case we want to show the number of visitors in our page, we must
use this kind of code :
| index.asp |
| There are <% =application("activevisitors") %> active visitors. |