...

View Full Version : Current # of Viewers viewing this site...



isaaclloyd
08-23-2005, 08:47 AM
I am trying to create a script where I can see the current # of visitors viewing my website. I am using a Global.asa file and here is what I have come up with:


Global.asa



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

Sub Application_OnEnd
'no code is needed here
End Sub


Sub Session_OnStart
Session.Timeout=20
Session("Start")=Now
Application.Lock
Application("Active")=Application("Active")+1
'this adds 1 to the number of active users
'when a new user hits
Application.unlock
End Sub

Sub Session_OnEnd
Application.Lock
Application("Active")=Application("Active")-1
'this subtracts 1 from the number of active users
'when a new user leaves
Application.unlock
End Sub




Viewers.asp



<%
Response.Write("There are " & Application("Active"))
Response.Write(" users on this page!")
%>



The problem is that I never get a number of current viewers when viewing the viewers.asp page. The viewers are tracked by sessions, so I test by opening FireFox and IE and going to the viewers page, but nothing. Any comments or suggestions would greatly be appreciated. Thanks.

~Isaac~

isaaclloyd
08-23-2005, 09:01 AM
I feel pretty stupid cause I found my answer a few monutes after I posted, but I searched and worked on the script for like 2 hours before posting. Anyways information about how to do this kind of script can be found here for anyone else who might want to do this: http://www.asp101.com/resources/active_users.asp


~Isaac~



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum