Example #1
0
        public void SetCookie(HttpCookie cookie)
        {
            if (_cookies == null)
                _cookies = new ArrayList();

            _cookies.Add(cookie);
        }
 public void Add(string name, HttpCookie value)
 {
     AddWithoutValidate(name, 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(name, value);
 }
 protected void AddWithoutValidate(string name, HttpCookie value)
 {
     _cookies.Add(value);
 }
Example #5
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;
        }