⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sessionmanager.cs

📁 简单的cI真的是很简单 你想要就下载吧
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public class SessionManager
{
    static public void SetSessionString(string SessionStringName, string strValue)
    {
        HttpContext.Current.Session[SessionStringName] = strValue;
    }
    static public string GetSessionString(string SessionStringName)
    {
        try
        {
            if (SessionStringName == null || SessionStringName == string.Empty || HttpContext.Current.Session[SessionStringName] == null)
                return string.Empty;

            return HttpContext.Current.Session[SessionStringName].ToString().Trim();
        }
        catch
        {
            return string.Empty;
        }
    }
    static public void SetSessionObject(string SessionObjectName, object objValue)
    {
        HttpContext.Current.Session[SessionObjectName] = objValue;
    }
    static public object GetSessionObject(string SessionObjectName)
    {
        try
        {
            if (SessionObjectName == null || SessionObjectName == string.Empty || HttpContext.Current.Session[SessionObjectName] == null)
            { return null; }
            object test = HttpContext.Current.Session[SessionObjectName];//测试

            return HttpContext.Current.Session[SessionObjectName];
        }
        catch
        {
            return null;
        }
    }

    static public void ClearAll()
    {
        HttpContext.Current.Session.Clear();
    }

    //public static void SaveCurrentUserInfo(UserType eType, object objBaseInfo)
    //{
    //    SetSessionObject(Consts.strUserType, eType);
    //    SetSessionObject(Consts.strUserInfo, objBaseInfo);
    //}

    //public static object GetCurrentUserInfo(ref UserType eType)
    //{
    //    eType = (UserType)(GetSessionObject(Consts.strUserType) == null ? UserType.None : GetSessionObject(Consts.strUserType));
    //    return GetSessionObject(Consts.strUserInfo);
    //}

    //public static void ClearCurrentUserInfo()
    //{
    //    SetSessionObject(Consts.strUserType, null);
    //    SetSessionObject(Consts.strUserInfo, null);
    //}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -