A user should be able to navigate to login screen in public site and also should be able to log out from public page if already logged in

Vote:
 

when i logout from my episerver edit mode it should automatically get logged out from my public website also and when i logout from my website it should also get loggedout from edit mode.

luckily i have managed to get through 1 of the functionalities.

when i logout from my website i am able to logout from edit mode.

below is the code for the same

if (Request.Cookies[".EPiServerLogin"] != null)
{
var c = new HttpCookie(".EPiServerLogin");
c.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(c);
}

if i login to edit mode it creates a cookie with name EPiServerLogin. At the time of logout from my website i am deleting EPiServerLogin cookie.

but how can i achieve it if i logout from edit mode it should get logout from my website as well.

comments appreciated

#151308
Jul 14, 2016 15:57
Vote:
 

This is normally the standard .NET functionality if you haven't done anything custom. Kill all cookies and redirect basically. You can normally use:

FormsAuthentication.SignOut();
Session.Abandon();

// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);

// clear session cookie (not necessary for your current problem but i would recommend you do it anyway)
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);

FormsAuthentication.RedirectToLoginPage();
#151309
Jul 14, 2016 16:18
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.