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; }
protected void AddWithoutValidate(HttpCookie value) { _cookies.Add(value); }
public void Add(HttpCookie value) { AddWithoutValidate(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); }