How to get Session Data with out having HttpContext.Current, by SessionID
Asked Answered
L

2

4

I am searching to find a way to read and write on session data but with out having the HttpContext. Current.

Why I won to do that ? because I wish to make some action with the user Session after the page have been close and unloaded.

For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext . Current is not exist any more.

So is there a way to read Session Data knowing just the session id.

I store my session inside an SQL server, and I see them. its there on table ASPStateTempSessions :)

How can I read them "offline" and manipulate them ?

Thank you in advanced.,

Laroche answered 5/5, 2010 at 8:18 Comment(0)
W
0

Still not quite clear why you might want to do that but you might not actually need to do it on Session_End(). At that point, it may be too late for you to work with the session data anyway (I've read some articles before about this). What might be a better solution is to actually attempt to work on the session data when your application actually has the context.

For example:

There's nothing to stop your application creating an asynchronous request on a new thread in the background (or even a different application, such as a Windows Service, for instance) when the specific session variable that you want is updated or has been set. This way, your application will be able to access the current HttpContext as well as all of the session data.

Not sure if this helps, but it was worth a shot ;)

Richard.

Waterman answered 5/5, 2010 at 15:40 Comment(1)
@Waterman Thank you for the replay.Dear Richard I have use asynchronous threads on the pages, but this is something different that I ask for some reason that is a little complicate to analyse. In sort its a manner of speed. I am working on many workaround but I just wondering if there is any way to read the session data of any user by just knowing the sessionid. To say it with other words, lets say that I need to debug all session data from all users and see whats on them - how can I do it ?Laroche
S
0

I may be a little late but... Today I found about the: System.Web.HttpRuntime.Cache

I know is not the same that a session but I think it's much better alternative that db. Regards.

Seacoast answered 3/12, 2010 at 19:25 Comment(1)
thank you for the answer. The session data is per user, but the cache is global. I search for something like that to be able to use the session user data on a stand alone thread.Laroche

© 2022 - 2024 — McMap. All rights reserved.