I Have looked around quite a bit and cannot find the exact answer I am looking for.
I want to know when the variables/values stored in HttpContext.Current.Session
will be cleared? Or does it never clear by itself?
Is it when the browser is closed? When the cache is cleared? When the session ends?
Also, does HttpContext.Current.Session
run in parallel to other sessions (other users won't be able to overwrite variables saved from my session's activity)?
I have noticed that HttpRuntime.Cache
is not parallel, so you can store things that are useful to all users and relatively static in here, which is nice, but I need some method to store information that are only applicable to the currently logged in user, and should not be overwritten by or seen by other user's sessions.
HttpContext.Current.Session
is the session for the current user.
It has default expiration of 20 minutes and the values will be lost after that. The values will be also lost if the user clears his cookies because the session id is stored in ASP.NET_SessionID cookie.
Here you can find more information about the session HttpContext.Session Property and HttpContext.Cache Property
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With