AppHarbor.Web.Security.CookieAuthenticator.SignOut C# (CSharp) Method

SignOut() public method

public SignOut ( ) : void
return void
	    public void SignOut()
		{
			_context.Response.Cookies.Remove(_configuration.CookieName);
			_context.Response.Cookies.Remove(".SessionExpire");

            var httpCookieNoDomain = new HttpCookie(_configuration.CookieName, "")
            {
                Expires = DateTime.UtcNow.AddMonths(-100),
            };
            _context.Response.Cookies.Add(httpCookieNoDomain);

            if (!string.IsNullOrEmpty(_configuration.Domain))
            {
                var httpCookieWithDomain = new HttpCookie(_configuration.CookieName, "")
                {
                    Expires = DateTime.UtcNow.AddMonths(-100),
                };
                httpCookieWithDomain.Domain = _configuration.Domain;
                _context.Response.Cookies.Add(httpCookieWithDomain);
            }

            _context.Response.Cookies.Add(new HttpCookie(".SessionExpire", "")
            {
                Expires = DateTime.UtcNow.AddMonths(-100),
            });
        }

Usage Example

Esempio n. 1
0
 public ActionResult LogOut()
 {
     //FormsAuthentication.SignOut();
     IAuthenticator authenticator = new CookieAuthenticator();
     authenticator.SignOut();
     Response.Clear();
     return Json(true);
 }