示例#1
0
        public static HttpCookie[] CookiesFromHeader(string httpHeader)
        {
            if (httpHeader == null)
                return null;

            ArrayList cookies = new ArrayList();

            foreach (string cookieStr in httpHeader.Split(';'))
            {
                string[] cookieParts = cookieStr.Split('=');

                if (cookieParts.Length != 2)
                    continue;

                HttpCookie cookie = new HttpCookie();
                cookie.Name = cookieParts[0];
                cookie.Value = cookieParts[1];

                cookies.Add(cookie);
            }

            HttpCookie[] res = new HttpCookie[cookies.Count];

            for (int i = 0; i < cookies.Count; i++)
            {
                res[i] = cookies[i] as HttpCookie;
            }

            return res;
        }
示例#2
0
 protected void AddWithoutValidate(HttpCookie value)
 {
     _cookies.Add(value);
 }
示例#3
0
 public void Add(HttpCookie value)
 {
     AddWithoutValidate(value);
 }
 public void Add(HttpCookie value)
 {
     AddWithoutValidate(value);
 }
 protected void AddWithoutValidate(HttpCookie value)
 {
     _cookies.Add(value);
 }
 public void Set(string name, HttpCookie value)
 {
     for (int i = 0; i < Count; i++)
     {
         HttpCookie cookie = (HttpCookie)_cookies[i];
         if (cookie.Name == name)
         {
             _cookies[i] = value;
             return;
         }
     }
     Add(value);
 }