Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a custom login in Sharepoint 2010 using claims-based authentication. User authentication works just fine but my custom sign out method doesn't. I have tried several solutions but my authentication cookie (federation) is still there. Why?

This will not work:

FormsAuthentication.SignOut();

Not this:

FederatedAuthentication.SessionAuthenticationModule.SignOut();
FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie();

Nor will this:

var authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
    HttpCookie cookie = new HttpCookie(authCookie.Name);
    cookie.Expires = DateTime.Now.AddDays(-1d);
    cookie.Domain = domain;
    Response.Cookies.Add(cookie);
}

How do I delete my FedAuth cookie? My cookie is not persistent. Still the only way to remove my auth cookie is deleting it manually in my browser or closing it down.

share|improve this question

1 Answer 1

We had some trouble with this while using WIF. I'm don't know if your SharePoint implementation uses WIF but, if it does, this is an alternative method that may help:

WSFederationAuthenticationModule authModule = FederatedAuthentication.WSFederationAuthenticationModule;
                string signoutUrl = (WSFederationAuthenticationModule.GetFederationPassiveSignOutUrl(authModule.Issuer, authModule.Realm, null));
                Response.Redirect(signoutUrl);
share|improve this answer
    
Thanks! No I don't use WIF, didn't even know about it. Looks very intresting thought, I will check it up! –  kolback May 17 '13 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.