mirror of
https://github.com/electron/electron.git
synced 2026-01-24 14:57:58 -05:00
2.3 KiB
2.3 KiB
cookies
The cookies module gives you ability to query and modify cookies, an example
is:
var cookies = require('cookies');
// Query all cookies.
cookies.get({}, function(error, cookies) {
if (error) throw error;
console.log(cookies);
});
// Query all cookies that are associated with a specific url.
cookies.get({ url : "http://www.github.com" }, function(error, cookies) {
if (error) throw error;
console.log(cookies);
});
// Set a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
cookies.set({ url : "http://www.github.com", name : "dummy_name", value : "dummy"},
function(error, cookies) {
if (error) throw error;
console.log(cookies);
});
cookies.get(details, callback)
detailsObjecturlString - Retrieves cookies which are associated withurl. Empty imples retrieving cookies of all urls.nameString - Filters cookies by namedomainString - Retrieves cookies whose domains match or are subdomains ofdomainspathString - Retrieves cookies whose path matchespathsecureBoolean - Filters cookies by their Secure propertysessionBoolean - Filters out session or persistent cookies.
callbackFunction - function(error, cookies)errorErrorcookiesArray - array of cookie objects.
cookies.set(details, callback)
-
detailsObjecturlString - Retrieves cookies which are associated withurlnameString - The name of the cookie. Empty by default if omitted.valueString - The value of the cookie. Empty by default if omitted.domainString - The domain of the cookie. Empty by default if omitted.pathString - The path of the cookie. Empty by default if omitted.secureBoolean - Whether the cookie should be marked as Secure. Defaults to false.sessionBoolean - Whether the cookie should be marked as HttpOnly. Defaults to false.expirationDateDouble - The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie.
-
callbackFunction - function(error)errorError
cookies.remove(details, callback)
detailsObjecturlString - The URL associated with the cookienameString - The name of cookie to remove
callbackFunction - function(error)errorError