private void CheckLogin() { var _clsGetUserLogin = new BllUser(); var cookie = new HttpCookie("login"); string strsession = LibHasCode.Encode.EncodePassword(txtPasswordLogin.Value); var _dtGetUserLogin = _clsGetUserLogin.GetUserLogin(txtUserNameLogin.Value, strsession); if (_dtGetUserLogin != null && _dtGetUserLogin.Rows.Count > 0) { if (txtUserNameLogin.Value.Trim() == _dtGetUserLogin.Rows[0]["UserName"].ToString() && strsession.Trim().ToUpper() == _dtGetUserLogin.Rows[0]["Password"].ToString() || txtUserNameLogin.Value.Trim() == _dtGetUserLogin.Rows[0]["Email"].ToString() && strsession.Trim().ToUpper() == _dtGetUserLogin.Rows[0]["Password"].ToString()) { if (chkRemember.Checked) { Session["login"] = true; Session["UserName"] = txtUserNameLogin.Value; Session["AccountID"] = _dtGetUserLogin.Rows[0]["AccountID"].ToString(); Session["Group_Id"] = _dtGetUserLogin.Rows[0]["Group_Id"].ToString(); Session["Lock"] = _dtGetUserLogin.Rows[0]["Lock"].ToString(); Session["FullName"] = _dtGetUserLogin.Rows[0]["FullName"].ToString(); Session["FullName1"] = _dtGetUserLogin.Rows[0]["UserName"].ToString(); cookie["UserName"] = Session["UserName"].ToString(); cookie["AccountID"] = Session["AccountID"].ToString(); cookie["Group_Id"] = Session["Group_Id"].ToString(); cookie["Lock"] = Session["Lock"].ToString(); cookie["FullName"] = Session["FullName"].ToString(); cookie["FullName1"] = Session["FullName1"].ToString(); cookie.Expires = DateTime.Now.AddDays(double.Parse(WebConfigurationManager.AppSettings["TimeOut"])); Response.Cookies.Add(cookie); Response.Redirect("/"); } else { Session["login"] = true; Session["UserName"] = txtUserNameLogin.Value; Session["AccountID"] = _dtGetUserLogin.Rows[0]["AccountID"].ToString(); Session["Group_Id"] = _dtGetUserLogin.Rows[0]["Group_Id"].ToString(); Session["Lock"] = _dtGetUserLogin.Rows[0]["Lock"].ToString(); Session["FullName"] = _dtGetUserLogin.Rows[0]["FullName"].ToString(); Session["FullName1"] = _dtGetUserLogin.Rows[0]["UserName"].ToString(); Response.Redirect("/"); } } else { _ErrorLogin = LibAlert.Alert.AlertError("Tên đăng nhập,tài khoản không chính xác hoặc đã bị khoá !"); Session["login"] = false; Session.RemoveAll(); Session.Abandon(); cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); //Response.Redirect("/login-page/"); } } else { _ErrorLogin = LibAlert.Alert.AlertError("Tên đăng nhập,tài khoản không chính xác hoặc đã bị khoá !"); Session["login"] = false; Session.RemoveAll(); Session.Abandon(); cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); //Response.Redirect("/login-page/"); } }