Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpContext.Current.Session Auto Expiration?

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.

like image 757
EternalWulf Avatar asked Sep 11 '25 14:09

EternalWulf


1 Answers

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

like image 189
nsgocev Avatar answered Sep 13 '25 03:09

nsgocev