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"];</p>

// do you thing with your object


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:




Published by

Alan Feekery

Developer, Gamer, Musician, Cyclist and big Motorsport fan... enjoys the odd cup of coffee :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s