Is there someway to get a list of activated sessions in classic ASP?
I want to limit the number of simultaneus activated sessions.
Is there someway to get a list of activated sessions in classic ASP?
I want to limit the number of simultaneus activated sessions.
Here is a good article which shows a way to do that: Active User Count Without Global.asa by Josh Painter
I guess you have to change some details, but this is the way you could approach the problem. The author doesn't use global.asa.
A simpler way would be to hook the Sesssion_OnStart
and Session_OnEnd
events in global.asa and adding/removing the item from the list of sessions implemented as an Application variable.
If you just want the count of sessions, you could simply doing it this way:
Sub Session_OnStart
Application.Lock
Application("count") = Application("count") + 1
Application.Unlock
End Sub
Sub Session_OnEnd
Application.Lock
Application("count") = Application("count") - 1
If Application("count") < 0 then ' Could only happen if some other function interfers
Application("count")=0
End If
Application.Unlock
End Sub
In your ASP file
<%
Response.Write "There are currently " & Application("count") & "active sessions>"
%>
You can't access one session from another, so there's no built-in way to get a list of all the active sessions. However, you can use Session_OnStart
and Session_OnEnd
in global.asa to track the sessions by saving the relevant session info to the Application
object, a log file, a database etc (depending on exactly what you want to do with the information).
We tend to track the number of active sessions in an Application
object to get a rough idea of how many people are using a site at any given time (bearing in mind, of course, that people will typically have left the site long before their sessions time out). It's not 100% accurate but it's close enough for a guide to current activity.
If you just want the number of sessions, you can also use Perfmon to track the Sessions Current
counter (and other related counters) for the Active Server Pages
performance object. Obviously this assumes access to the server and probably isn't what you want in this case.
For more info on some options, try this article: How do I count the number of current users / sessions?