Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void CreateCookie(string user, string password, bool isAuth = false)
- {
- const string cookiesName = "AUTH_COOKIES";
- FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), isAuth, password, FormsAuthentication.FormsCookiePath);
- HttpCookie cookies = new HttpCookie(cookiesName)
- {
- Value = FormsAuthentication.Encrypt(ticket),
- Expires = DateTime.Now.Add(FormsAuthentication.Timeout)
- };
- Response.Cookies.Add(cookies);
- }
- public UserInfo GetCookies(string encryptCookie)
- {
- var decryptCookies = FormsAuthentication.Decrypt(encryptCookie);
- return new UserInfo() { Username = decryptCookies.Name, Password = decryptCookies.UserData };
- }
Add Comment
Please, Sign In to add comment