Clearing session data in ASP.NET

Sometimes you find you might need to clear out session data in ASP.NET, there are two ways to do this, either using Session.Abandon() which will reset your ASP.NET_sessionId cookie value or Session.Clear() which will clear out all the content from the session. Below is the source code for using these two methods.

//destroys the session and the Session_OnEnd event is triggered in the global.asax

//removes all values (content) from the Object, the session with the same key is still alive.


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