I just launched my first MVC3 application and everything works fine except cookies authorisation. When a user visits my site and logs in I set a .ASPAUTH cookie with data about that user. It works well untill some time passes. Then I have to log in again even though the cookie is in the browser and I can see that expiration is set to one year later. It works fine on my localhost. It seems to me that it instead of setting my info into cookie it is somehow in session, but even if I restart my computer within an hour I am still logged in. But if I don't visit the web in 1 hour, after that I am logged out.
Thanks for any help.
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
requestedUser.Name,
DateTime.Now,
DateTime.Now.AddYears(1),
true,
string.Format("{0};{1};{2}", requestedUser.IDUser.ToString(), requestedUser.IsAdmin.ToString(), profilePicture));
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
cookie.Expires = keepLogged == "keepLogged" ? DateTime.Now.AddYears(1) : DateTime.Now.AddHours(1);
this.Response.Cookies.Add(cookie);
return RedirectToAction("Index", "Posts");