System.Net.CookieContainer Class

Provides a container for a collection of System.Net.CookieCollection objects.

See Also: CookieContainer Members

Syntax

public class CookieContainer

Remarks

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

An instance of the System.Net.Cookie class is added to the container based on its originating URI. It is added to an internal System.Net.CookieCollection associated with the URI. A System.Net.Cookie is retrieved from the container based on the URI as a System.Net.CookieCollection, or as a string that can be used to submit HTTP WebRequests.

The System.Net.CookieContainer has three properties that govern the volume of the content of the container: CookieContainer.Capacity, CookieContainer.MaxCookieSize, and CookieContainer.PerDomainCapacity. These values have the default settings of 300, 4096, and 20 respectively. When a System.Net.Cookie is added to the container, these properties are used to determine whether a System.Net.Cookie already contained in the System.Net.CookieContainer should be discarded to make room for the new one. The System.Net.CookieContainer keeps track of each addition to ensure that neither the CookieContainer.Capacity nor the CookieContainer.PerDomainCapacity limits are exceeded. If one or both are exceeded, then System.Net.Cookie instances held by the System.Net.CookieContainer are removed. First, any expired System.Net.Cookie is removed. If further capacity must be recaptured, then the least-recently used System.Net.CookieCollection is purged.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0