public void LogOut() { var httpCookie = new HttpCookie(cookieName) { Value = string.Empty, Expires = DateTime.Now }; AuthCookieProvider.SetCookie(httpCookie); }
private void CreateCookie(string userName, bool isPersistent = false) { var ticket = new FormsAuthenticationTicket( 1, userName, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), isPersistent, string.Empty, FormsAuthentication.FormsCookiePath); // Encrypt the ticket. var encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. var AuthCookie = new HttpCookie(cookieName) { Value = encTicket, Expires = DateTime.Now.Add(FormsAuthentication.Timeout) }; AuthCookieProvider.SetCookie(AuthCookie); }