WebBrowser GetCookieValue Method C# API
Gets the value of the specified cookie, at the specified domain and path.

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

public virtual string GetCookieValue(
	string domain,
	string path,
	string cookieName
)

Parameters

domain
Type: System String
The domain of the cookie.
path
Type: System String
The path within the domain of the cookie.
cookieName
Type: System String
The name of the cookie.

Return Value

The value of the key/value pair stored as a cookie at the specified domain and path.
Remarks

A cookie stored at a particular path is available to all paths below it in the hierarchy.
Examples

The following example demonstrates getting the cookie value at different paths 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 stored at this path
http://www.mycookiesite.com:8080/cookies/           // Cookie SESSIONID stored here
http://www.mycookiesite.com:8080/cookies/howto      // SESSIONID available here
http://www.mycookiesite.com:8080/cookies/howto/bake // SESSIONID available here
// assuming the cookie has been set as above, 
// the following calls can be made to obtain the value of SESSIONID 
string cookie;
cookie = WebBrowser.GetCookieValue("www.mycookiesite.com", "/cookies/", "SESSIONID");
cookie = WebBrowser.GetCookieValue("www.mycookiesite.com", "/cookies/howto/", "SESSIONID");
cookie = WebBrowser.GetCookieValue("www.mycookiesite.com", "/cookies/howto/bake/", "SESSIONID");

// the following call will not return a value as the path "/" 
// is above the path at which the cookie is stored ("/cookies")
cookie = WebBrowser.GetCookieValue("www.mycookiesite.com", "/", "SESSIONID");
See Also