ASPX templates
Version 5.x > ASPX templates > Programatically logout a user View modes: 
User avatar
Member
Member
Ian Muir - 3/28/2011 1:19:15 PM
   
Programatically logout a user
I've created a custom login page that seems to be working fine on my site, but I can't get the user logged out.

I'm calling FormsAuthentication.SignOut(); but I'm pretty sure there is something else I should be calling because the user stays logged in. Has anybody done this yet? Any pointers would be helpful.

User avatar
Member
Member
kentico_michal - 3/28/2011 1:27:42 PM
   
RE:Programatically logout a user
Hi Ian,

You could use following code to sign out a user:

System.Web.Security.FormsAuthentication.SignOut();
CMS.CMSHelper.CMSContext.ClearShoppingCart();
CMS.CMSHelper.CMSContext.CurrentUser = null;


Anyway, there is a web part in Kentico CMS intended for signing out users. So, you might find some inspiration how to log out the user in a following file ~\CMSWebParts\Membership\Logon\SignOutButton.ascx.cs


Best regards,
Michal Legen