WebBrowser SaveCookie Method C# API
Saves cookie data for the specified host.

Namespace: Facilita.Web
Assembly: clrWebBrowser (in clrWebBrowser.dll) Version: 9.5.5.77 (1.0.0.0)
Syntax

public virtual void SaveCookie(
	string host,
	string data
)

Parameters

host
Type: System String
The target domain.
data
Type: System String
The cookie name and value, in the form of a Set-Cookie header.
Remarks

The host must be a hostname or TCP/IP address. Use this call to populate a browser with a set of pre-defined cookies or to add a cookie to the browser cookie cache.

The cookie data is in the form of a "Set-Cookie" header as received from a server.

Examples

The following example demonstrates saving a cookie, and example URLs at which the saved cookie value will be available.
WebBrowser.SaveCookie("www.mycookiesite.com", "SESSIONID=99; path=/cookies; expires=Mon, 01-Jan-2003 00:00:00 GMT");
A path may be specified in the data, in which case the cookie value is only available at that path and any paths below it in the hierarchy.
Set-Cookie: SESSIONID=99; path=/cookies; expires=Mon, 01-Jan-2003 00:00:00 GMT

http://www.mycookiesite.com:8080/                   // No cookie available at this path
http://www.mycookiesite.com:8080/cookies/           // Cookie SESSIONID=99 stored here
http://www.mycookiesite.com:8080/cookies/howto      // SESSIONID=99 available here
http://www.mycookiesite.com:8080/cookies/howto/bake // SESSIONID=99 available here
If no path is specified, the path will default to "/". This causes the cookie to be sent on all requests to the domain.
See Also