Clearing ASP.NET Session Data
The current project I am working on has me making a good bit of use of Session variables. One thing that I was not sure about was how to delete specific session variables or even maybe clear out all session data.
Thankfully this is quite easy. =D
Create session data and then removing it: (aDrvier is a wrapper class of basic driver details containing strings, datetimes and ints.)
Session[“AdditionalDriverOne”] = aDriver;
AdditionalDriver newADriver = (AdditionalDriver)Session[“AdditionalDriverOne”];
// do you thing with your object
Session.Remove(“AdditionalDriverOne”);
It’s that simple, if you want to clear out all session data at some point in your application then all you have to do is:
Session.RemoveAll();
Resource: beansoftware.com
