The number of online visits is a very concern to every netizen who builds a website. How do you know how many people are visiting your website? How to record the number of visits every day? Here is a solution.
When a user starts to access the website, Global.asa on the server will be accessed. A session will be enabled for the user. You can set your own personal user information for each user. I won't explain much here. In Global.asa there are message response functions when Application starts and Session starts. You can type in the following code.
The code copy is as follows:
<SCRIPTLANGUAGE="VBScript"RUNAT="Server">
SubApplication_OnStart
'When the server is turned on, set the number of users to 0
Application("Users")=0
EndSub
SubSession_OnStart
Session.Timeout=20
'The number of users is added to 1 when starting a session
Application.Lock
Application("Users")=Application("Users")+1
Application.UnLock
EndSub
SubSession_OnEnd
'The user counter is decremented by 1 when a session is finished
Application.Lock
Application("Users")=Application("Users")-1
Application.UnLock
EndSub
</SCRIPT>
When the website is running, the Application variable Application ("Users") will always record the number of people online on the website. The number of online users can be written out using any web page. As for recording, there are many methods that can be used. If it is recorded in a file, you can use the Scripting.FileSystemObject object for processing. If logged into the database, you can use ADO and so on. I won't introduce them one by one here.