← Back to Network domain
Network.setCookie
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
Domain: Network
stable
Parameters
| Name | Type | Description |
name | string | Cookie name. |
value | string | Cookie value. |
url (optional) | string | The request-URI to associate with the setting of the cookie. This value can affect the
default domain, path, source port, and source scheme values of the created cookie. |
domain (optional) | string | Cookie domain. |
path (optional) | string | Cookie path. |
secure (optional) | boolean | True if cookie is secure. |
httpOnly (optional) | boolean | True if cookie is http-only. |
sameSite (optional) | CookieSameSite | Cookie SameSite type. |
expires (optional) | TimeSinceEpoch | Cookie expiration date, session cookie if not set |
priority (optional) | CookiePriority | Cookie Priority type. |
sourceScheme (optional) | CookieSourceScheme | Cookie source scheme type. |
sourcePort (optional) | integer | Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
This is a temporary ability and it will be removed in the future. |
partitionKey (optional) | CookiePartitionKey | Cookie partition key. If not set, the cookie will be set as not partitioned. |
Returns
| Name | Type | Description |
success | boolean | Always set to true. If an error occurs, the response indicates protocol error. |
Example Request
{
"id": 1,
"method": "Network.setCookie",
"params": {
"name": "example-name",
"value": "example-value"
}
}
Example Response
{
"id": 1,
"result": {
"success": true
}
}
Usage in Node.js
const result = await send('Network.setCookie', {"name": "example-name", "value": "example-value"});
console.log(result);
// {"success": true}