Cookies

session.getAllCookies()

Returns all cookies associated with the address of the current browsing context’s active document.

RETURNS

Promise<Cookie[]>

EXAMPLES

const cookies = await session.getAllCookies();
// cookies = [
//   {
//     name: 'cookie name',
//     value: 'cookie value',
//     path: '/',
//     domain: 'localhost',
//     secure: false,
//     httpOnly: true
//   }
// ]

SEE ALSO

session.getNamedCookie(name)

Returns cookie based on the cookie name

PARAMETERS

  • name: string - Name of the cookie object to be returned

RETURNS

Promise<Cookie>

EXAMPLES

const cookie = await session.getNamedCookie('cookieName');

SEE ALSO

Adds a single cookie to the cookie store associated with the active document’s address.

PARAMETERS

  • cookie: Cookie - Cookie object to add in browser for current domain

RETURNS

Promise<void>

EXAMPLES

await session.addCookie({ name: 'test cookie', value: 'test value' });

SEE ALSO

session.deleteCookie(propertyName)

Delete a cookie based on its name

PARAMETERS

  • propertyName: string - Cookie name to delete

RETURNS

Promise<void>

EXAMPLES

await session.deleteCookie('cookieName');

SEE ALSO

session.deleteAllCookies()

Delete all cookies associated with the address of the current browsing context’s active document.

RETURNS

Promise<void>

EXAMPLES

await session.deleteAllCookies();

SEE ALSO

An object defining the cookie.

PROPERTIES

  • name: string - The name of the cookie.

  • value: string - The cookie value.

  • path?: string - The cookie path. Defaults to "/" if omitted when adding a cookie.

  • domain?: string - The domain the cookie is visible to. Defaults to the current browsing context’s document’s URL domain if omitted when adding a cookie.

  • secure?: boolean - Whether the cookie is a secure cookie. Defaults to false if omitted when adding a cookie.

  • httpOnly?: boolean - Whether the cookie is an HTTP only cookie. Defaults to false if omitted when adding a cookie.

  • expiry?: number - When the cookie expires, specified in seconds since Unix Epoch. Defaults to 20 years into the future if omitted when adding a cookie.

Last updated