Display the Number of Users Online

The codes contain two parts. The first part is part of the "global.asa" file which is to be placed directly under your root directory. The second part is the code to display the actual number of people online. You can also easily use the Client's Info code to find out your visitor's IP address and the time they visited your site.

The Code:
'--- codes to be placed in global.asa 
<script language=VBScript runat=Server> 
Sub Application_OnStart
     Application("WhoOn") = 0
 End Sub
 
Sub Application_OnEnd
     '---nothing here
 End Sub
 
Sub Session_OnStart
     Session.Timeout = 20
     '---lock Application variable before updating
     Application.Lock
         Application("WhoOn") = Application("WhoOn") + 1
     Application.Unlock
 End Sub
 
Sub Session_OnEnd
     Application.Lock
     Application("WhoOn") = Application("WhoOn") - 1
     Application.Unlock
 End Sub
 
</script>


code to display the actual number online
<%=Application("WhoOn")%> users online now

The Result

Number of Users on psacake.com now: 508

ASP active server pages number of users online


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site