How to use ASP to record the number of online users

Source: Internet
Author: User

The access volume of the network is a matter of great concern to all netizens who work on the website. How many people are visiting your website? How to record the daily traffic volume? The following is a solution.
When a user starts to access the website, the Global. asa on the server side will be accessed. A Session is enabled for the user. You can set personal user information for each user. I will not explain it here. In Global. asa, message response functions are provided when Application and Session are started. You can enter the following code.
<Script language = "VBScript" RUNAT = "Server">
Sub Application_OnStart
'When the server is enabled, set the number of users to 0.
Application ("Users") = 0
End Sub
Sub Session_OnStart
Session. Timeout = 20
'The number of users increases by 1 when a Session starts
Application. Lock
Application ("Users") = Application ("Users") + 1
Application. UnLock
End Sub
Sub Session_OnEnd
'When a Session ends, the user counter minus 1
Application. Lock
Application ("Users") = Application ("Users")-1
Application. UnLock
End Sub
</SCRIPT>

When the website is running, the Application Variable Application ("Users") keeps recording the number of online Users of the website. You can use the number of online users on any web page. As for the record, you can use many methods. If it is recorded in a file, you can use the Scripting. FileSystemObject object for processing. If it is recorded in the database, you can use ADO and so on. Here we will not introduce them one by one.


Related Article

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.