Parcourir la source

删除 'LoginState.cs'

master
童毓泽 il y a 3 ans
Parent
révision
8c7ffd17f7
1 fichiers modifiés avec 0 ajouts et 82 suppressions
  1. +0
    -82
      LoginState.cs

+ 0
- 82
LoginState.cs Voir le fichier

@ -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
{
/// <summary>
/// 检测会员登录状态
/// </summary>
public class LoginState
{
/// <summary>
/// 判断用户是否登录
/// </summary>
/// <param name="objUserName"></param>
/// <returns></returns>
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("<script>");
System.Web.HttpContext.Current.Response.Write("parent.location.href='login.aspx?jump=" + System.Web.HttpContext.Current.Server.UrlEncode(URL) + "'");
System.Web.HttpContext.Current.Response.Write("</script>");
}
}
/// <summary>
/// 判断管理员是否已经登录(解决Session超时问题)
/// </summary>
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;
}
/// <summary>
/// 取得管理员信息
/// </summary>
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;
}
}
}

Chargement…
Annuler
Enregistrer