Описание тега cookiecontainer

Provides a container for a collection of CookieCollection objects.

In C#:

A CookieContainer is a data structure that provides storage for instances of the Cookie class, and which is accessed in a database-like manner. The CookieContainer has a capacity limit that is set when the container is created or changed by a property.

One might use a CookieContainer in conjunction with a CookieCollection object for persisting HTTP cookies between HttpWebRequests and HttpWebResponses.

Some example usage:

CookieContainer container = new CookieContainer();
CookieCollection cookies = new CookieCollection();

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://somesite.com/login");
request.CookieContainer = container;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookies = response.Cookies; // capture the cookies from the response

request = (HttpWebRequest)WebRequest.Create("http://somesite.com/profile");
request.CookieContainer = container;
// capture the cookies from the response for sending with a request
request.CookieContainer.Add(cookies);

response = (HttpWebResponse)request.GetResponse();
// capture the cookies from the response for sending with a request
cookies = response.Cookies;