ASP Statistics Online number Global.asa

Source: Internet
Author: User

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")%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.