Export (0) Print
Expand All

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 _
)
[C#]
public void SetCookies(
 Uri uri,
 string cookieHeader
);
[C++]
public: void SetCookies(
 Uri* uri,
 String* cookieHeader
);
[JScript]
public function SetCookies(
   uri : Uri,
 cookieHeader : String
);

Parameters

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

Exceptions

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

Remarks

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.

Requirements

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

Show:
© 2015 Microsoft