How to use ASP to record the number of online users

Source: Internet
Author: User
Online | The amount of Internet access 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

   ' Set the number of users to 0 when the server is turned on

Application ("Users") = 0

End Sub

Sub Session_OnStart

Session.Timeout = 20

   ' When starting a session, the number of users plus 1

Application.Lock

Application ("users") = Application ("users") + 1

Application.UnLock

End Sub

Sub Session_OnEnd

   ' user counter minus 1 when ending a session

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.