Ejemplo n.º 1
0
        /// <summary>
        /// 获取管理员的信息
        /// </summary>
        /// <returns></returns>
        public static string Getljsheng(string field)
        {
            HttpCookie ck   = HttpContext.Current.Request.Cookies["LJSheng"];
            JObject    json = JsonConvert.DeserializeObject(DESRSA.DESDeljsheng(StringTranscoding.UnEscape(ck.Value.ToString()))) as JObject;

            return(json[field].ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取Cookie
        /// </summary>
        /// <param name="CookieName">Cookie 名称</param>
        /// <returns></returns>
        public static string GetCookie(string CookieName)
        {
            HttpCookie ck = HttpContext.Current.Request.Cookies[CookieName];

            if (ck == null)
            {
                return(null);
            }
            else
            {
                return(StringTranscoding.UnEscape(ck.Value.ToString()));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取用户访问的项目类型
        /// </summary>
        public static int Project()
        {
            HttpCookie ck = HttpContext.Current.Request.Cookies["project"];

            if (ck == null)
            {
                return(0);
            }
            else
            {
                return(int.Parse(StringTranscoding.UnEscape(ck.Value.ToString())));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 读取后台城市Cookie
        /// </summary>
        /// <param name="CookieName">Cookie 名称</param>
        /// <returns></returns>
        public static string GetAdminCity()
        {
            HttpCookie ck = HttpContext.Current.Request.Cookies["AdminCity"];

            if (ck == null)
            {
                return("福州市");
            }
            else
            {
                return(StringTranscoding.UnEscape(ck.Value.ToString()));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取用户登录Cookie的商家GID
        /// </summary>
        /// <returns></returns>
        public static Guid GetShopGid()
        {
            HttpCookie ck = HttpContext.Current.Request.Cookies["shop"];

            if (ck != null)
            {
                JObject json = JsonConvert.DeserializeObject(DESRSA.DESDeljsheng(StringTranscoding.UnEscape(ck.Value.ToString()))) as JObject;
                return(Guid.Parse(json["Gid"].ToString()));
            }
            else
            {
                return(Guid.Parse("00000000-0000-0000-0000-000000000000"));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取商家登录Cookie的GID
        /// <param name="lx">1=用户GID 2=商家GID</param>
        /// </summary>
        /// <returns></returns>
        public static Guid GetShop(int lx)
        {
            HttpCookie ck   = HttpContext.Current.Request.Cookies["shop"];
            JObject    json = JsonConvert.DeserializeObject(DESRSA.DESDeljsheng(StringTranscoding.UnEscape(ck.Value.ToString()))) as JObject;

            if (lx == 1)
            {
                return(Guid.Parse(json["gid"].ToString()));
            }
            else
            {
                return(Guid.Parse(json["shopgid"].ToString()));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 添加Cookie
        /// </summary>
        /// <param name="CookieName">Cookie 名称</param>
        /// <param name="CookieValuer">Cookie 值</param>
        /// <param name="Day">Cookie 保存时间</param>
        public static void AddCookie(string CookieName, string CookieValuer, int Day)
        {
            HttpCookie ck = HttpContext.Current.Request.Cookies[CookieName];

            if (ck != null)
            {
                //存在删除重新增加
                HttpContext.Current.Response.Cookies.Remove(CookieName);
            }
            ck       = new HttpCookie(CookieName);
            ck.Value = StringTranscoding.Escape(CookieValuer);
            //ck.Domain = System.Web.Configuration.WebConfigurationManager.AppSettings["CookieDomain"].ToString();
            ck.Path = "/";
            if (Day != 0)
            {
                ck.Expires = DateTime.Now.AddDays(Day);
            }
            HttpContext.Current.Response.Cookies.Add(ck);
        }