ICookieStoreSetCookie Method |
Sets a session cookie given explicit user-provided cookie attributes and associate
it with the given url.
Namespace:
DotNetBrowser.Cookies
Assembly:
DotNetBrowser (in DotNetBrowser.dll) Version: 2.0.0
SyntaxTask<bool> SetCookie(
string url,
Cookie cookie
)
Parameters
- url
- Type: SystemString
A valid URL, which host will be associated
with a new cookie instance. The url string must be
valid and has the following format: http[https]://host. For example,
http://www.google.com, https://www.gmail.com etc.
- cookie
- Type: DotNetBrowser.CookiesCookie
An HTTP cookie.
Return Value
Type:
TaskBooleantrue when session cookie was inserted successfully,
false otherwise.
Exceptions| Exception | Condition |
|---|
| ArgumentException |
The cookie is null, or the url is null,
empty, or contains blank characters.
|
| ObjectDisposedException | The ICookieStore has already been disposed. |
Remarks
If
url and
cookie.Domain.Domain are different, the cookie will not be set
and the method returns
false. So, make sure that
url and
cookie domain are the same domains. For example, for http://www.teamdev.com
address the cookie domain must be
.teamdev.com
If you set the cookie successfully and the method returns
true and you
decide to find the cookie in the list of all cookies, please note that
the cookie storage can modify some cookies attributes, such as domain or expiration time.
See Also