Web - Accessing Current Sessions?

  • Thread starter Thread starter David P. Donahue
  • Start date Start date
D

David P. Donahue

Is there a way to iterate through some kind of collection and access
session variables in current active sessions on the website?

For example, I'd like to add a feature to an administrative section of a
website that will show the admin a given session variable ("username"
for example) for every active session. Other info, like IP addresses of
users and whatnot, would also be useful. Can this be done? Where would
I find this information?


Regards,
David P. Donahue
(e-mail address removed)
 
Hi David,

The first thought that comes to mind is to implement a collection for each
attribute at your web application "application level". Those objects are
initialized along with your web application. So when users get logged in or
change session variables that you want to track you can at the same time
update your application level objects and that will persist the data for as
long as the web application is running.
 
Hi,

I haven't heard of any property/method of the HttpApplication class for
this, what you can do is using the feature of asp.net for keep a session
info in a SQL server, using this environment you can query the tables and
get the info you need.

also try to do a google search, I bet you are not the first one with this
request.

cheers,
 
Ya, I've been trying Google from time to time, and I've found some stuff
that kind of touches on the issue, but nothing that fits my needs.
Mostly 3rd party controls, which may or may not work in my environment
anyway.

I figured I could store the info in the database when sessions begin and
remove it when sessions end, but I was hoping to avoid any kind of I/O
if I could. The information is already in memory, I guess the .NET
libraries just don't have a way of getting to it. Having a Sessions
collection in the Application object would just be so damn useful :)


Regards,
David P. Donahue
(e-mail address removed)
 
Hi,

Just be careful with storing a reference to the Session in the application,
doing so may prevent those objects from be GCed

cheers,
 
Back
Top