This documentation is archived and is not being maintained.

CookieContainer.SetCookies Method

Adds Cookie instances for one or more cookies from an HTTP cookie header to the CookieContainer for a specific URI.

[Visual Basic]
Public Sub SetCookies( _
   ByVal uri As Uri, _
   ByVal cookieHeader As String _
public void SetCookies(
 Uri uri,
 string cookieHeader
public: void SetCookies(
 Uri* uri,
 String* cookieHeader
public function SetCookies(
   uri : Uri,
 cookieHeader : String


The URI of the CookieCollection.
The contents of an HTTP set-cookie header as returned by a HTTP server, with Cookie instances delimited by commas.


Exception Type Condition
ArgumentNullException uri is a null reference (Nothing in Visual Basic)
ArgumentNullException cookieHeader is a null reference (Nothing in Visual Basic)


SetCookies pulls all the HTTP cookies out of the HTTP cookie header, builds a Cookie for each one, and then adds each Cookie to the internal CookieCollection associated with the URI. The HTTP cookies in the cookieHeader string must be delimited by commas.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

CookieContainer Class | CookieContainer Members | System.Net Namespace | Cookie | CookieCollection | CookieContainer | CookieException