views:

70

answers:

3

Hi all I am trying to find out in my asp.net application the users that are currently logged in the application by searching on the session info. Currently, I am only able to see my current session, but I cannot find out if there are other users using it. Is there a way to see if there are other users using the applicatin by looking at the session information

Many thanks in advanced guys!!

+3  A: 

Session state is per user - Application state (global) seems to be what you're looking for. There are 2 hashes Session and Application, in which you can store key-value pairs.

A way to do it would be to update Application[UserNamesList] whenever there is a successful login. This would then be visible to all users. Application state would however be lost whenever the App Web Server recycles or restarts... but that shouldn't be a problem in this case.

Gishu
@Javier- Just remember to lock/unlock the application object if you decide to use it.
RichardOD
A: 

A session is supposed to only give you information about the currently logged-in user.

If you need to keep track of all logged-in users, you could consider writing the users into a global variable. Here is info on how that works. Note that sessions expire. You would have to write, for each user, the time the user was last seen (i.e. each time they hit a new page, update their record). When the time they were last seen is greater than your session timeout, it's safe to assume they are no longer logged in and you can remove them from the list of current users. If they just up and close their browser, you will not be alerted and you will still think they are logged in even though they are not.

Eric J.
+1  A: 

See this link.

danish
+1 as they are using lock/unlock, which many people seem to forget to do.
RichardOD