private void AddCookie(LogOnModel model) { var cookie = new HttpCookie("userinfo"); cookie.Values["UserName"] = model.UserName; cookie.Values["Password"] = model.Password; Response.Cookies.Add(cookie); }
public ActionResult LogOn(LogOnModel model) { if (ModelState.IsValid) { //check user & password if (CheckLogin(model.UserName, model.Password)) { AccessFactory.Login(model.UserName); //save cookie if (model.RememberMe) AddCookie(model); else ClearCookie(); if (AccessFactory.CurrentUserRole == (int)UserGroup.SALE) return RedirectToAction("Index", "Customer"); else if (AccessFactory.CurrentUserRole == (int)UserGroup.SALE_MANAGER) return RedirectToAction("CustomerList", "Sale"); else if (AccessFactory.CurrentUserRole == (int)UserGroup.COMPANY_OWNER) return RedirectToAction("SaleManager", "Manager"); } else { model.Errors = "Tài khoản hoặc mật khẩu không chính xác."; } } // If we got this far, something failed, redisplay form return View(model); }