private void CheckLogin() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { pnlCookie.Visible = false; pnlLogin.Visible = true; } else { string BaseUserName = Cookie.Values["UserName"]; string BaseUserPassword = Cookie.Values["Password"]; string NickName = Cookie.Values["NickName"]; if (la.ChkAdminExit(BaseUserName, BaseUserPassword)) { lbNICK_NAME.Text = NickName; pnlCookie.Visible = true; pnlLogin.Visible = false; } else { pnlCookie.Visible = false; pnlLogin.Visible = true; } } }
protected void lbtnExit_Click(object sender, EventArgs e) { HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie != null) { Cookie = new HttpCookie(SiteInfo.CookieName()); Cookie.Values.Add("UserId", ""); Cookie.Values.Add("UserName", ""); Cookie.Values.Add("Password", ""); Cookie.Values.Add("NickName", ""); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddDays(-1); CookiesHelper.AddCookie(Cookie); } pnlCookie.Visible = false; pnlLogin.Visible = true; }
private bool CheckLogin() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { return(false); } BaseUserName = Cookie.Values["UserName"]; BaseUserPassword = Cookie.Values["Password"]; BaseNickName = Cookie.Values["NickName"]; BaseUserID = Cookie.Values["UserId"]; if (la.ChkAdminExit(BaseUserName, BaseUserPassword)) { return(true); } else { return(false); } }
public static bool CheckLoginLxj() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { return(false); } string BaseUserName1 = Cookie.Values["UserName"]; string BaseUserPassword1 = Cookie.Values["Password"]; string BaseNickName1 = Cookie.Values["NickName"]; string BaseUserID1 = Cookie.Values["UserId"]; if (la.ChkAdminExit(BaseUserName1, BaseUserPassword1)) { return(true); } else { return(false); } }
protected void ibLogin_Click(object sender, ImageClickEventArgs e) { string name = txtUSERNAME.Text; string password = txtPassword.Text; if ("".Equals(name)) { return; } if ("".Equals(password)) { return; } string UserName = name; string ConfirmPassword = Names.EncryptPassword(password); if (la.ChkAdminExit(UserName, ConfirmPassword)) { DataTable DT = la.GetAdminInfo(UserName); if (DT.Rows.Count == 0) { MessageBox("该用户不存在!"); return; } else if (DT.Rows[0]["NB_ZT"].ToString() == "0") { MessageBox("该用户已无效!"); return; } else { HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { Cookie = new HttpCookie(SiteInfo.CookieName()); Cookie.Values.Add("UserId", DT.Rows[0]["NB_ID"].ToString()); Cookie.Values.Add("UserName", DT.Rows[0]["VAR_ZH"].ToString()); Cookie.Values.Add("Password", DT.Rows[0]["VAR_MM"].ToString()); Cookie.Values.Add("NickName", DT.Rows[0]["VAR_NICK_NAME"].ToString()); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddDays(1); CookiesHelper.AddCookie(Cookie); } if (Cookie.Values.Count <= 0) { Cookie = new HttpCookie(SiteInfo.CookieName()); Cookie.Values.Add("UserId", DT.Rows[0]["NB_ID"].ToString()); Cookie.Values.Add("UserName", DT.Rows[0]["VAR_ZH"].ToString()); Cookie.Values.Add("Password", DT.Rows[0]["VAR_MM"].ToString()); Cookie.Values.Add("NickName", DT.Rows[0]["VAR_NICK_NAME"].ToString()); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddDays(1); CookiesHelper.AddCookie(Cookie); } else if ((!Cookie.Values["UserName"].Equals(DT.Rows[0]["VAR_ZH"].ToString())) || (!Cookie.Values["Password"].Equals(DT.Rows[0]["VAR_MM"].ToString()))) { CookiesHelper.SetCookie(SiteInfo.CookieName(), "UserId", DT.Rows[0]["NB_ID"].ToString()); CookiesHelper.SetCookie(SiteInfo.CookieName(), "UserName", DT.Rows[0]["VAR_ZH"].ToString()); CookiesHelper.SetCookie(SiteInfo.CookieName(), "Password", DT.Rows[0]["VAR_MM"].ToString()); CookiesHelper.SetCookie(SiteInfo.CookieName(), "NickName", DT.Rows[0]["VAR_NICK_NAME"].ToString()); } lbNICK_NAME.Text = DT.Rows[0]["VAR_NICK_NAME"].ToString(); pnlCookie.Visible = true; pnlLogin.Visible = false; return; } } else { MessageBox("用户名或密码错误!"); return; } }