How to use ASP to record the number of online users

Source: Internet
Author: User

The amount of traffic on the web is a matter of great concern to every netizen who makes a website. How do you know how many people are visiting your website? How do I record the amount of visits I make every day? Here is a solution.

When a user starts to visit the site, the server-side global.asa will be accessed. A session will be opened for the user. You can set up your own personal user information for each user. There's not much to explain here. There is a message response function in Global.asa when the application starts and session starts. You can typing the following code.

< SCRIPT LANGUAGE="VBScript" RUNAT="Server" >
Sub Application_OnStart
’ 当服务器开启时,设置用户数为0
Application ("Users") = 0
End Sub
Sub Session_OnStart
Session.Timeout = 20
’ 当开始一个Session时用户数加1
Application.Lock
Application ("Users") = Application("Users") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
’ 当结束一个Session时用户计数器减1
Application.Lock
Application("Users") = Application("Users") - 1
Application.UnLock
End Sub
< /SCRIPT >

When the site is run, the Application variable application ("Users") will keep track of the number of online sites. You can use the number of online users to write on any Web page. As for records, you can use a number of methods. If you are logging into a file, you can use the Scripting.FileSystemObject object for processing. If you log in to the database, you can use ADO and so on. Here is not a description.

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.