Code for recording the number of online users using ASP

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 . Copy code The Code is as follows: <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.