CookieDetails
The cookie to store, as passed to cookies.set().
Example
import { session } from '@mobrowser/api';
await session.cookies.set({
url: 'https://example.com',
name: 'theme',
value: 'dark',
expirationDate: Date.now() / 1000 + 60 * 60 * 24 * 365
})
Properties
url
readonly url: string;
The URL the cookie is stored against.
It decides which existing cookies the new one may overwrite, and whether the scheme is allowed to store cookies at all. The call is rejected when the URL is not valid.
name
readonly name?: string;
The name of the cookie. Defaults to an empty string.
value
readonly value?: string;
The value of the cookie. Defaults to an empty string.
domain
readonly domain?: string;
The domain of the cookie.
Pass a leading dot to make the cookie apply to subdomains as well.
Defaults to the host of url, which makes a host-only cookie.
path
readonly path?: string;
The path of the cookie. Defaults to the path of url.
secure
readonly secure?: boolean;
Whether the cookie is sent over secure connections only. Defaults to false.
httpOnly
readonly httpOnly?: boolean;
Whether the cookie is hidden from scripts running in the page. Defaults to false.
expirationDate
readonly expirationDate?: number;
When the cookie expires, in seconds since the UNIX epoch.
Leave it out to store a session cookie, which is discarded when the application quits.
sameSite
readonly sameSite?: CookieSameSite;
The SameSite policy to apply. Defaults to unspecified.