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
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
name?: string;
The name of the cookie. Defaults to an empty string.
value
value?: string;
The value of the cookie. Defaults to an empty string.
domain
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
path?: string;
The path of the cookie. Defaults to the path of url.
secure
secure?: boolean;
Whether the cookie is sent over secure connections only. Defaults to false.
httpOnly
httpOnly?: boolean;
Whether the cookie is hidden from scripts running in the page. Defaults to false.
expirationDate
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
sameSite?: CookieSameSite;
The SameSite policy to apply. Defaults to unspecified.