public ActionResult SignIn(SignInVM User) { //add fullname and userid to vm if (ModelState.IsValid) { Users u = new Users(); if (u.Authenticate(User.Login, User.Passkey)) { DateTime exDate = User.RememberMe ? DateTime.Now.AddMonths(6) : DateTime.Now.AddDays(1); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, u.UserID, DateTime.Now, exDate, true, u.Fullname, FormsAuthentication.FormsCookiePath); AppUtility.SetCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket), exDate, FormsAuthentication.RequireSSL); AppUtility.SetCookie("UserFName", u.FirstName); AppUtility.SetCookie("DeviceType", AppUtility.GetDeviceType()); if (string.IsNullOrEmpty(User.ReturnUrl)) { return(Redirect(FormsAuthentication.DefaultUrl)); } else { return(Redirect("~" + HttpUtility.UrlDecode(User.ReturnUrl))); } } else { ModelState.AddModelError("", Users.ReturnMessage); TempData["SignInMsg"] = Users.ReturnMessage; return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError("", "Provide login and password"); TempData["SignInMsg"] = "Provide login and password"; return(RedirectToAction("Index", "Home")); }