How to clear out session on log out
Session.Abandon()
http://msdn.microsoft.com/en-us/library/ms524310.aspx
Here is a little more detail on the HttpSessionState
object:
http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate_members.aspx
I use following to clear session and clear aspnet_sessionID
:
HttpContext.Current.Session.Clear();HttpContext.Current.Session.Abandon();HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
I would prefer Session.Abandon()
Session.Clear()
will not cause End to fire and further requests from the client will not raise the Session Start event.