ASP.NET Login/Membership - How to logout?

Aximili picture Aximili · Oct 20, 2011 · Viewed 18.6k times · Source

I am using the <asp:LoginStatus> control (along with <asp:Login>)

I login successfully as A.
Then I logout.
If I then login as B, the current user is still A.
(Both <asp:LoginName> and HttpContext.Current.User.Identity.Name are showing A)

I have to clear the cookies to completely logout.

Why doesn't the .NET login control log me out properly? Anyone has any idea?

EDIT: I apologize everyone! This is an Umbraco bug. I forgot I was using UmbracoMembershipProvider

Answer

Ira Rainey picture Ira Rainey · Oct 20, 2011

On logout to completely clear out the logged in user I would use:

Session.Clear()
Session.Abandon()
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()