ASP: Online Users Counter

Posted By Venu Thomas

This popular script is found in almost all sites in ASP, used to count visitors assets (present at the time), is on our website.

The code should be used in the file Global.asa. Must not be enclosed in <% and%> must be unique and that has within it. (Well, not unique, but playing with Global.asa not recommend it).

Here’s the code that goes into the Global.asa

<script language=vbscript runat=server> 

Sub Application_OnStart
Application("Active") = 0
End Sub 

Sub Application_OnEnd
End Sub 

Sub Session_OnStart
Application.Lock
Application("Active") = Application("Active") + 1
Application.Unlock
End Sub 

Sub Session_OnEnd
Application.Lock
Application("Active") = Application("Active") - 1
Application.Unlock
End Sub 

</script>

And to show the information which the Global.asa, or to show active users as I did in my example, they should put the following on the page displaying the data:

<P>There are currently <%=Application("Active")%> user's on our site</P>

Happy Programming!!! ;)

Tags: , ,

  •  
  • Share with others:

    Thanks for visiting us! If you enjoyed these icons please feel free to share them! Or if you want to know what's going on with WiseCodes.com, follow us!

    Leave a Reply

    Anti-Spam Protection by WP-SpamFree

    Locations of visitors to this page eXTReMe Tracker