Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP counter using global.asa

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
A well-known site advertised the following code:

<%
Sub Session_OnStart
Application.Lock
Application(&quot;Sessions&quot;) = Application(&quot;Sessions&quot;)+1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application(&quot;Sessions&quot;) = Application(&quot;Sessions&quot;)-1
If Application(&quot;Sessions&quot;) < 0 Then Application(&quot;Sessions&quot;)=0
Application.UnLock
End Sub
%>

This code is to be placed in the global.asa file and is meant to show the number of users on the site when the following code is placed on a web page;

<%= &quot;Number of users on-line: &quot; & Application(&quot;Sessions&quot;)%>

I've tried the above code unsuccessfully. I'd really like to use this counter for a site - could anyone tell me what could be wrong?

Cheers


 
The problem with this is that you can not count on the Session On_End event firing everytime a session times out. If you force an abandon (Session.Abandon) it executes flawlessly (a log-out link for example) but how often does everyone log out 'correctly' from every site they visit? I gave up on this method a LONG time ago. In IIS 4.0 (and from what I hear, it's still a bug in 5.0) this issue is still unresolved. Look for another means of keeping track because that event is not reliable. I use a database table to keep track of users when they come on and off and I set my own 'timeout' time and remove them with code. This of course works like a champ.

I hope you are able to come up with another solution easily. =) Ed (RoadRacer) Holguin

&quot;I Hate Computers!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top