public ActionResult Login(LoginViewModel model) { var resultado = servicio.ObtenerUsuario(model.Email, model.Clave); if (resultado != null) { var userData = JsonConvert.SerializeObject(resultado); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, resultado.Email, DateTime.Now, DateTime.Now.AddHours(8), true, userData, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); cookie.HttpOnly = true; Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Home")); } return(View(model)); }