Question

Is there a method in code to access the Session objects for all current site users, read their session info and make changes to them?

In a web application I'm working with, an Admin user will make a change which affects one or more users. However each user caches that information in their Session when they log in. So I need some way of either updating their Session data directly, or somehow notifying the affected users to re-load the data from the database.

We don't want them hitting the database for that info on every request, so ideally it must only happen when required. If accessing other users' Session collections is impossible, are there other (non-database) methods in ASP.NET for directly notifying specific users that an event has taken place?


(Just thought of one possible method after writing that.. using an Application variable that holds a list of all user IDs which need to update their cached data. As each user does so, they remove their ID from the list.. so that's one approach.. are there any others?)

Was it helpful?

Solution

I didn't know you could do this but I did some googling and apparently it is possible as mentioned in this article:

http://weblogs.asp.net/imranbaloch/archive/2010/04/05/reading-all-users-session.aspx

I found the link from this Stack Overflow question: List all active ASP.NET Sessions

Once you have the list I'm assuming the code will also allow you to edit the list... but that might require some more research and trial/error...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top