/// <summary> /// 判断管理员是否已经登录(解决Session超时问题) /// </summary> public bool IsAdminLogin() { //如果Session不为Null if (Session["admin_userid"] != null && Session["issystem"] != null && Session["Permissions"] != null) { return(true); } else { //检查Cookies string adminname = Utils.GetCookie("AdminName", "FZtouch"); //解密用户名 string adminpwd = Utils.GetCookie("AdminPwd", "FZtouch"); if (adminname != "" && adminpwd != "") { adminname = DESEncrypt.Decrypt(adminname); //解密用户名 AdminUserBLL bll = new AdminUserBLL(); AdminUser item = bll.UserLogin(adminname, adminpwd); if (item != null) { Session["admin_userid"] = item.Id; Session["issystem"] = item.IsSystem; Session["Permissions"] = bll.GetPermissionsByUserID(item.Id); return(true); } } } return(false); }
/// <summary> /// 用户登录 /// </summary> /// <param name="UserName">用户名</param> /// <param name="UserPwd">密码</param> /// <returns>登录是否成功</returns> private bool UserLogin(string UserName, string UserPwd) { AdminUserBLL UserBiz = new AdminUserBLL(); AdminUser item = UserBiz.UserLogin(UserName, UserPwd); if (item != null) { Session["AdminName"] = UserName; Session["admin_userid"] = item.Id; Session["admin_show"] = 1; Session["issystem"] = item.IsSystem; Session["Permissions"] = UserBiz.GetPermissionsByUserID(item.Id); UserBiz.UpdateUser(item.Id, Utils.GetTrueIPAddress()); //写入Cookies Utils.WriteCookie("AdminName", "FZtouch", DESEncrypt.Encrypt(UserName)); Utils.WriteCookie("AdminPwd", "FZtouch", UserPwd); return(true); } else { return(false); } }