Check out
this explanation and code for clearing the session and authentication cookies.
In the responses in that article, people are telling that the
SignOut Method doesn't remove the authentication ticket, so after calling the SignOut method you need to remove it anyway. This is non-sense. If the Signout method would not remove the authentication ticket, why calling it? The one and only thing the SignOut
method should be doing is to remove the authentication cookie, and I never any experienced a bug in this....
Marked as answer by Ming Xu - MSFT on May 31, 2012 12:46 PM
mcupryk
Member
243 Points
392 Posts
Login and Logout Cookie
May 03, 2012 05:22 PM|LINK
If I need to write the logout for the following login:
bool AutoLoginCheckBox = ((Login)this.LoginView.FindControl("LoginControl")).RememberMeSet; string username = ((Login)this.LoginView.FindControl("LoginControl")).UserName; AutoLoginCookie alCookie = new AutoLoginCookie(); if (!alCookie.HasValue || (alCookie.HasValue && (alCookie.GetValue() != AutoLoginCheckBox))) { alCookie.Write(AutoLoginCheckBox); } HttpCookie formsAuthCookie; formsAuthCookie = FormsAuthentication.GetAuthCookie(username, AutoLoginCheckBox); UserCookie userCookie = csContext.User.GetUserCookie(); userCookie.WriteCookie(formsAuthCookie, 30, AutoLoginCheckBox);grundebar
Contributor
4515 Points
726 Posts
Re: Login and Logout Cookie
May 03, 2012 09:42 PM|LINK
Check out this explanation and code for clearing the session and authentication cookies.
Remeber to Mark as Answer if this post helped you.
hans_v
All-Star
35986 Points
6550 Posts
Re: Login and Logout Cookie
May 05, 2012 08:03 AM|LINK
In the responses in that article, people are telling that the SignOut Method doesn't remove the authentication ticket, so after calling the SignOut method you need to remove it anyway. This is non-sense. If the Signout method would not remove the authentication ticket, why calling it? The one and only thing the SignOut method should be doing is to remove the authentication cookie, and I never any experienced a bug in this....