日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用于读、写、删除、比较Session中的用户信息的类库。

發布時間:2024/10/8 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用于读、写、删除、比较Session中的用户信息的类库。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?/// <summary>
??? /// 用于讀、寫、刪除、比較Session中的用戶信息。
??? /// </summary>
??? [Serializable]
??? public class SessionBox
??? {
??????? private SessionBox() { }

??????? #region 用戶Session操作

??????? /// <summary>
??????? /// 檢測User Session是否存在
??????? /// </summary>
??????? /// <returns></returns>
??????? public static bool CheckUserSession()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["USER"];
??????????? if (o == null)
??????????????? return false;
??????????? else
??????????????? return true;

??????? }

??????? /// <summary>
??????? /// 登記User Session
??????? /// </summary>
??????? /// <param name="userinfo"></param>
??????? public static void CreateUserSession(UserSession userinfo)
??????? {
??????????? System.Web.HttpContext.Current.Session["USER"] = userinfo;
??????? }

??????? /// <summary>
??????? /// 獲取User Session
??????? /// </summary>
??????? /// <returns></returns>
??????? public static UserSession GetUserSession()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["USER"];
??????????? if (o == null) throw new ExceptionSession("讀取UserSession失敗。");
??????????? else return (o as UserSession);
??????? }

??????? /// <summary>
??????? /// 移除User Session
??????? /// </summary>
??????? public static void RemoveUserSession()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["USER"];
??????????? if (o != null) System.Web.HttpContext.Current.Session.Remove("User");
??????? }

??????? #endregion

??????? #region 模塊Session操作

??????? /// <summary>
??????? /// 登記Moudule Session
??????? /// </summary>
??????? /// <param name="lists"></param>
??????? public static void CreateModuleList(ArrayList lists)
??????? {
??????????? System.Web.HttpContext.Current.Session["MODULE_TAG"] = lists;
??????? }

??????? /// <summary>
??????? /// 讀取模塊權限
??????? /// </summary>
??????? /// <returns></returns>
??????? public static ArrayList GetModuleList()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["MODULE_TAG"];
??????????? if (o == null) throw new ExceptionSession("讀取權限失敗。");
??????????? else return (o as ArrayList);
??????? }

??????? /// <summary>
??????? /// 移除模塊權限
??????? /// </summary>
??????? public static void RemoveModuleList()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["MODULE_TAG"];
??????????? if (o != null)
??????????? {
??????????????? System.Web.HttpContext.Current.Session.Remove("MODULE_TAG");
??????????????? //在移除模塊權限時也清掉它的ID
??????????????? System.Web.HttpContext.Current.Session.Remove("MID");
??????????? }
??????? }

??????? #endregion

??????? #region 當前已登錄會員對當前模塊的權限集合

??????? /// <summary>
??????? /// 創建模塊權限列表
??????? /// </summary>
??????? /// <param name="lists"></param>
??????? public static void CreateAuthority(ArrayList lists)
??????? {
??????????? System.Web.HttpContext.Current.Session["Authority"] = lists;
??????? }

??????? /// <summary>
??????? /// 讀取模塊權限
??????? /// </summary>
??????? /// <returns></returns>
??????? public static ArrayList GetAuthority()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["Authority"];
??????????? if (o == null) throw new ExceptionSession("讀取權限失敗。");
??????????? else return (o as ArrayList);
??????? }

??????? /// <summary>
??????? /// 移除模塊權限
??????? /// </summary>
??????? public static void RemoveAuthority()
??????? {
??????????? object o = System.Web.HttpContext.Current.Session["Authority"];
??????????? if (o != null) System.Web.HttpContext.Current.Session.Remove("Authority");
??????? }

??????? #endregion
??? }

轉載于:https://www.cnblogs.com/xwnet/archive/2012/02/10/2345646.html

總結

以上是生活随笔為你收集整理的用于读、写、删除、比较Session中的用户信息的类库。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。