コード例 #1
0
        public void SetCookie(HttpCookie cookie)
        {
            if (_cookies == null)
                _cookies = new ArrayList();

            _cookies.Add(cookie);
        }
コード例 #2
0
 public void Add(string name, HttpCookie value)
 {
     AddWithoutValidate(name, value);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 protected void AddWithoutValidate(string name, HttpCookie value)
 {
     _cookies.Add(value);
 }
コード例 #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;
        }