setCookie()
Sets a cookie with the given cookie data. It may overwrite equivalent cookie if it already exists.
Examples
Section titled “Examples”await setCookie("CSRFToken","csrfToken", {url: "http://the-internet.herokuapp.com"})await setCookie("CSRFToken","csrfToken", {domain: "herokuapp.com"})Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name | string | Cookie name. |
value | string | Cookie value. |
options | Object | Default: {}. |
options.url | string | sets cookie with the URL. Default: undefined. |
options.domain | string | sets cookie with the exact domain. Default: undefined. |
options.path | string | sets cookie with the exact path. Default: undefined. |
options.secure | boolean | True if cookie to be set is secure. Default: undefined. |
options.httpOnly | boolean | True if cookie to be set is http-only. Default: undefined. |
options.sameSite | string | Represents the cookie’s ‘SameSite’ status: Refer https://tools.ietf.org/html/draft-west-first-party-cookies. Default: undefined. |
options.expires | number | UTC time in seconds, counted from January 1, 1970. eg: 2019-02-16T16:55:45.529Z Default: undefined. |
Returns
Section titled “Returns”| Type | Description |
|---|---|
Promise<void> |