Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear out session on log out

I redirect the user to the login page when user click log out however I don't think it clears any application or session because all the data persisted when the user logs back in.

Currently the login page has a login control and the code behind on the page is only wired up the login Authenticate.

Can someone direct me to a good tutorial or article about handling log in and out of ASP.NET web sites?

like image 374
Jack Avatar asked Dec 05 '08 21:12

Jack


People also ask

How to clear session after logout?

session["username"] = ""; session. clear(); session. abandon();

How to clear session after logout in ASP net?

Session. Clear() will not cause End to fire and further requests from the client will not raise the Session Start event.

How do I clear Httpcontext current session?

Session. Clear() just removes all values (content) from the Object. The session with the same key is still alive.


1 Answers

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

like image 110
Ryan Cook Avatar answered Sep 28 '22 03:09

Ryan Cook