Link to home
Start Free TrialLog in
Avatar of julesuk
julesuk

asked on

ASP Session Checking

From an administration screen I want to be able to see a list off all current sessions. I do not need to see any of the session variables (but am interested if this can be done). I just want to know if session xxxxxxx is still active.
Avatar of sybe
sybe

Give every user an Application variable. They work the same as Session variables (so they time out at the same time) and are shared among all users. Make a "secret page" which will display all current application variables.
Avatar of julesuk

ASKER

How does this work if the number of users grows? Does the user list have to be a constant for this to work, eg. setup 100 variables to support 100 users? Could you please provide a sample of the code required to do this, i.e. both setting up the application variable and also how to list all current application variables.
<script language=VBScript runat=Server>
Sub Application_OnStart
      Application("WhoOn") = 0
End Sub

Sub Application_OnEnd

End Sub

Sub Session_OnStart
      Session.Timeout = 20

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

Sub Session_OnEnd
      Application.Lock
            Application("WhoOn") = Application("WhoOn") - 1
      Application.Unlock
End Sub
</script>


Then in a page, use:

<%=Applicaiton("WhoOn") %> to get the number of concurrent users.

ASKER CERTIFIED SOLUTION
Avatar of MasseyM
MasseyM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial