View Full Version : Online Users Counter
Scrowler
07-28-2003, 08:47 PM
I use global.asa to count how many users are online, but when I show the script on the page it doesn't show the number, the script is something like:
<% response.write(Application("onlinevisitors")) %>
Any idea why it doesn't display the number?
Probably cause you got an error somewhere.
But without seeing the code you use to set/increment the counter, there's not a lott we can say ...
Morgoth
07-29-2003, 04:09 AM
Is your global.asa called G.L.O.B.A.L. DOT(.) A.S.A
It's a simple question, but some people usually forget or get mistaken, and they spell it wrong, or have ASP instead of ASA.
The inside of your global.asa looks like:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
Application("ActiveUsers") = 0
End Sub
Sub Session_OnStart
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 20
' Set a Session Start Time
' This is only important to assure we start a session
Session("Start") = Now()
' Increase the active visitors count when we start the session
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
' Decrease the active visitors count when the session ends.
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
</SCRIPT>
If not, why not use this code? This code works, and all you have to do is place:
There are <b><%=Application("ActiveUsers")%></b> Active Users online.
Fun, easy, and works well.
And later, when you have memberships on your site, you can do something like:
There are <b><%=Application("ActiveUsers") - IntMembersOnline%></b> Guests online.
<br>
There are <b><%=IntMembersOnline%></b> Members online.
IntMembersOnline = The amount of logged in people you have at your site ;)
Hope this helps.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.