The CookieStorage class allows you to get set and remove cookies from the main frame of the current tab. It mimics the W3C Storage api, but has slightly different parameters to deal with cookie settings.
CookieStorage cannot be instantiated. You must retrieve a cookieStorage instance from a Tab:
const cookieStorage = agent.activeTab.cookieStorage;
Returns the number of cookies for the current tab origin;
Promise<number>
Gets all cookies for the current tab origin as Cookie
objects.
Cookie
properties:string
. The cookie name.string
. The cookie value.string
. The cookie domain.string
. The path for the cookie.string
. An optional expiration date string.boolean
. Whether only accessible via http requests.boolean
. Whether the cookie should expire after the active session is over.boolean
. Whether the cookie should only apply to https secured urls.Strict | Lax | None
. The same site setting for the cookie.Promise<Cookie[]>
Gets the cookie with the given name
equal to keyName
.
string
. The cookie name to retrieve.Promise<Cookie[]>
An integer representing the number of the key you want to get the name of. This is a zero-based index. NOTE: key is equivalent to the name
of a cookie.
number
. The key index.Promise<string>
The function below calls a callback for each cookie key (or name).
function forEachKey(callback) {
for (var i = 0; i < cookieStorage.length; i++) {
callback(cookieStorage.key(i));
}
}
Removes a cookie with the given keyName
.
string
. The cookie name.Promise<boolean>
Sets a cookie for the currently loaded origin.
string
. The cookie name.string
. The cookie value.Data
. An optional expiration date for the cookie.boolean
. Whether to set the cookie to be only accessible via http requests.boolean
. If the cookie should only apply to https secured urls.Strict | Lax | None
. The same site setting for the cookie.Promise<boolean>