Process:
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
Instances of the Cookies
class are accessed by using cookies
property of
a Session
.
For example:
The following events are available on instances of Cookies
:
Event: ‘changed’
event
Eventcookie
- The cookie that was changed.cause
string - The cause of the change with one of the following values:explicit
- The cookie was changed directly by a consumer’s action.expired
- The cookie was automatically removed as it expired.evicted
- The cookie was automatically evicted during garbage collection.expired-overwrite
- The cookie was overwritten with an already-expired expiration date.
removed
boolean -true
if the cookie was removed,false
otherwise.
Emitted when a cookie is changed because it was added, edited, removed, or expired.
Instance Methods
The following methods are available on instances of :
cookies.get(filter)
filter
Objecturl
string (optional) - Retrieves cookies which are associated withurl
. Empty implies retrieving cookies of all URLs.name
string (optional) - Filters cookies by name.domain
string (optional) - Retrieves cookies whose domains match or are subdomains ofdomains
.path
string (optional) - Retrieves cookies whose path matchespath
.secure
boolean (optional) - Filters cookies by their Secure property.session
boolean (optional) - Filters out session or persistent cookies.
Returns Promise<Cookie[]>
- A promise which resolves an array of cookie objects.
Sends a request to get all cookies matching filter
, and resolves a promise with
the response.
cookies.set(details)
Sets a cookie with details
.
cookies.remove(url, name)
url
string - The URL associated with the cookie.name
string - The name of cookie to remove.
Returns Promise<void>
- A promise which resolves when the cookie has been removed
Removes the cookies matching url
and name
cookies.flushStore()
Returns Promise<void>
- A promise which resolves when the cookie store has been flushed