cookieaccessor.cs

来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 64 行

CS
64
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace DataAccess
{
    public class CookieAccessor
    {
        public string GetLoginUserName()
        {
            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["UserName"];
                return cookie.Value;
            }
            catch
            {
                return "";
            }
            
        }

        public int GetLoginUserRolesID()
        {
            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["RolesID"];
                return int.Parse(cookie.Value);
            }
            catch
            {
                return 0;
            }
        }

        public string GetLoginUserID()
        {
            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["UserID"];
                return cookie.Value;
            }
            catch
            {
                return "";
            }
        }

        public int GetLoginUserOperationID()
        {
            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["OperationID"];
                return int.Parse(cookie.Value);
            }
            catch
            {
                return 0;
            }
        }
    }
}

⌨️ 快捷键说明

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