Ejemplo n.º 1
0
        private void SetCookieValue(string key, string value)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(this.Name);

            if (cookie == null)
            {
                cookie = new HttpCookie(this.Name);
                HttpContext.Current.Response.AppendCookie(cookie);
            }
            if (string.IsNullOrEmpty(value))
            {
                cookie.Values.Remove(key);
            }
            else if (this.Encrypt)
            {
                cookie.Values[key] = DESC.Encrypt(value);
            }
            else
            {
                cookie.Values[key] = value;
            }
            if (this.Expires != 0)
            {
                cookie.Expires = this.CacluteExpiresTime();
            }
            HttpContext.Current.Response.SetCookie(cookie);
        }
Ejemplo n.º 2
0
        private string GetCookieValue(string key)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(this.Name);

            if (cookie == null)
            {
                return(null);
            }
            if (this.Encrypt)
            {
                return(DESC.Decrypt(cookie.Values[key]));
            }
            return(cookie.Values[key]);
        }