I know two way for authentication:
first: using FormsAuthentication:
FormsAuthentication.SetAuthCookie(login.UserName, login.RememberMe);
and the other way : using FormsAuthenticationTicket
var ticket = new FormsAuthenticationTicket(1, user.Email.ToString(), DateTime.Now, DateTime.Now.AddSeconds(300000), login.RememberMe, "a");
var ticketEncrypted = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie("eshop", ticketEncrypted);
if (login.RememberMe)
{
cookie.Expires = DateTime.Now.AddMinutes(100);
}
HttpContext.Response.Cookies.Add(cookie);
i want to know which one is better? and when i should use first one and when the other way?