How does an ASP site get the number of online users?

Source: Internet
Author: User
Online | My Global.asa file is as follows:
<script language= "VBScript" runat= "Server" >
' Session_OnStart run when a customer first runs any page in an ASP application
' Session_OnEnd run when a client's session times out or quits the application
' Application_OnStart run when any customer first accesses the first page of the application
' Application_OnEnd run when the Web server for the site is down

Sub Application_OnStart

Visitorcountfilename = Server.MapPath (".. /visitcount.txt ")
Set FileObject = Server.CreateObject ("Scripting.FileSystemObject")
Set out= Fileobject.opentextfile (Visitorcountfilename, 1, false, False)
Application ("visitors") = Out.readline
Application ("Nowpeoplenumber") =0
Application ("visitorcountfilename") = Visitorcountfilename
End Sub
'=========================================================
SUB Application_OnEnd
Set fileoutobject = Server.CreateObject ("Scripting.FileSystemObject")
Set out= fileoutobject.createtextfile (Application ("Visitorcountfilename"), True,false)
Out.writeline (Application ("visitors"))
End Sub
'=========================================================
Sub Session_OnStart
Session.Timeout = 30
Application ("visitors") = Application ("visitors") + 1
Application ("Nowpeoplenumber") =application ("Nowpeoplenumber") +1
Session ("ID") =session.sessionid
Session ("UserName") =0 ' does not exist
End Sub
'=========================================================
Sub Session_OnEnd
Application ("Nowpeoplenumber") =application ("Nowpeoplenumber")-1
End Sub
</SCRIPT>
In this case, the total number of visitors will be saved in the VisitCount.txt file, I think application ("Nowpeoplenumber") should be saved
Number online, show it on the home page, but doing so I found when I closed the browser when I opened the homepage
The number of online people increased by 1. That is to say Session_OnEnd is not executed. What's the reason? There are other ways to get it.
Number of people online? Thank you for your first post.




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.