From 8c7ffd17f7bfb5fa12c97e4c7d0ef812a65eeea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A5=E6=AF=93=E6=B3=BD?= <13204402429@stu.ecnu.edu.cn> Date: Sun, 17 Jan 2021 21:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'LoginState.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LoginState.cs | 82 ----------------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 LoginState.cs diff --git a/LoginState.cs b/LoginState.cs deleted file mode 100644 index c23044a..0000000 --- a/LoginState.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Data; -using System.Configuration; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; - -namespace Basic.Tools -{ - /// - /// 检测会员登录状态 - /// - public class LoginState - { - /// - /// 判断用户是否登录 - /// - /// - /// - public static void UserSession() - { - Basic.Model.user muser = Basic.Tools.LoginState.GetUserInfo(); - if (muser == null) - { - string URL = "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.RawUrl; - System.Web.HttpContext.Current.Response.Write(""); - } - } - - /// - /// 判断管理员是否已经登录(解决Session超时问题) - /// - public static bool IsUserLogin() - { - //如果Session为Null - if (System.Web.HttpContext.Current.Session[Keys.SESSION_USER_INFO] != null) - { - return true; - } - else - { - //检查Cookies - string username = Basic.Tools.Utils.GetCookie("UserName", "str_key"); //解密用户名 - string userpwd = Basic.Tools.Utils.GetCookie("UserPwd", "str_key");//解密密码 - if (username != "" && userpwd != "") - { - - DAL.user dal = new DAL.user(); - Model.user model = dal.GetModel(username, userpwd); - if (model != null) - { - System.Web.HttpContext.Current.Session[Keys.SESSION_USER_INFO] = model; - return true; - } - } - } - return false; - } - /// - /// 取得管理员信息 - /// - public static Model.user GetUserInfo() - { - if (IsUserLogin()) - { - Basic.DAL.user dal = new DAL.user(); - Model.user model = System.Web.HttpContext.Current.Session[Keys.SESSION_USER_INFO] as Model.user; - model = dal.GetModel(model.id); - if (model != null) - { - return model; - } - } - return null; - } - } -}