Cookies
6.8.3The Cookies API enables your web app to manage cookies. You can get a list of cookies by applying a filter that will be matched against all cookies, and also set and modify cookies, or remove cookies by name and URL.
The Cookies API is accessible through the io.cookies
object.
APIobject
Description
Cookies API.
Methods
getmethod
Signature
(filter?: CookiesGetFilter) => Promise<Cookie[]>
Description
Retrieves a list of cookies matching an optional filter object. If no filter is specified, will return all cookies.
Parameters
Name | Type | Required | Description |
---|---|---|---|
filter | CookiesGetFilter | Filter object that will be matched against all cookies. Only the cookies whose properties match the properties specified in the filter object will be returned. |
removemethod
Signature
(url: string, name: string) => Promise<void>
Description
Removes a cookie with the specified URL and name.
Parameters
Name | Type | Required | Description |
---|---|---|---|
url | string | URL of the cookie to remove. |
|
name | string | Name of the cookie to remove. |
setmethod
Signature
(cookie: CookiesSetDetails) => Promise<void>
Description
Sets a cookie or modifies an existing one with the specified values.
Parameters
Name | Type | Required | Description |
---|---|---|---|
cookie | CookiesSetDetails | Specifies which properties of the cookie to set. |
Cookieobject
Description
Describes a cookie.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
domain | string | Domain for the cookie. Normalized with a preceding dot in order to be valid for subdomains too. |
||
expirationDate | number | Expiration date of the cookie as a number of seconds since the UNIX epoch. Not available for session cookies. |
||
hostOnly | boolean | If |
||
httpOnly | boolean | If |
||
name | string | Name of the cookie. |
||
path | string | Path for the cookie. |
||
sameSite | "unspecified" | "no_restriction" | "lax" | "strict" | The value applied to the |
||
secure | boolean | If |
||
session | boolean | If |
||
value | string | Value of the cookie. |
CookiesGetFilterobject
Description
Filter object whose properties will be matched against all cookies to be retrieved.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
domain | string | Retrieves the cookies whose domains match or are subdomains of the specified domain. |
||
name | string | Filters the cookies by name. |
||
path | string | Retrieves the cookies whose paths match the specified path. |
||
secure | boolean | Filters cookies by their |
||
session | boolean | If |
||
url | string | Retrieves the cookies which are associated with the specified URL. If not specified, will retrieve the cookies for all URLs. |
CookiesSetDetailsobject
Description
Describes the cookie to set.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
domain | string | Domain for the cookie. Will be normalized with a preceding dot in order to be valid for subdomains too. |
||
expirationDate | number | The expiration date of the cookie as a number of seconds since the UNIX epoch. If not specified, the cookie will become a session cookie and won't be persisted between sessions. |
||
httpOnly | boolean | false | If |
|
name | string | Name for the cookie. |
||
path | string | Path for the cookie. |
||
sameSite | "unspecified" | "no_restriction" | "lax" | "strict" | "lax" | The value to be applied to the |
|
secure | boolean | false | If |
|
url | string | URL to associate with the cookie. |
||
value | string | Value for the cookie. |