I am working on ASP.NET MVC5 application and I want to implement RememberMe functionality. Here, when the user check RememberMe then, the username should be automatically fetch to username field, whenever the user go to the website again. I have tried with following methods. But it has problem with it and i am not able to done this. Can anyone help me to do this?
var authTicket = new FormsAuthenticationTicket(
1,
userId, //user id
DateTime.Now,
DateTime.Now.AddMinutes(50), // expiry
model.RememberMe, //true to remember
string.Empty
);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket));
if (authTicket.IsPersistent)
{
cookie.Expires = authTicket.Expiration;
}
System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
Thanks in advance.