Пример #1
0
        private void SetAuthenticationCookie(IAccount account, bool isPersistent)
        {
            var ticket = new FormsAuthenticationTicket(1,
                                                        account.Email,
                                                        DateTime.Now,
                                                        DateTime.Now.AddMinutes(30),
                                                        isPersistent,
                                                        account.ToObjectString(),
                                                        FormsAuthentication.FormsCookiePath);

            var strEncryptedTicket = FormsAuthentication.Encrypt(ticket);
            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, strEncryptedTicket);
            Response.Cookies.Add(cookie);
        }