Handstage exposes cookie and header management directly onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/l-xiaoshen/handstage/llms.txt
Use this file to discover all available pages before exploring further.
V3Context — the object accessible via handstage.context. These methods talk to Chrome over CDP and apply context-wide, so they affect every page and frame within the context.
Cookies
Get cookies
context.cookies(urls?) returns all cookies in the browser context. Pass one or more URLs to filter by domain and path:
Cookie object has these fields:
| Field | Type | Description |
|---|---|---|
name | string | Cookie name. |
value | string | Cookie value. |
domain | string | Domain the cookie is scoped to. |
path | string | URL path the cookie is scoped to. |
expires | number | Expiry as a Unix timestamp in seconds. -1 means the cookie is a session cookie. |
httpOnly | boolean | Whether the cookie is inaccessible to JavaScript. |
secure | boolean | Whether the cookie is only sent over HTTPS. |
sameSite | "Strict" | "Lax" | "None" | Cross-site request behavior. |
Add cookies
context.addCookies(cookies) injects one or more cookies. Each entry must specify either a url (from which the domain, path, and secure flag are derived) or an explicit domain + path pair:
CookieParam type supports these fields:
| Field | Type | Description |
|---|---|---|
name | string | Cookie name (required). |
value | string | Cookie value (required). |
url | string | Derive domain, path, and secure from this URL. Use this or domain+path. |
domain | string | Cookie domain. |
path | string | Cookie path. |
expires | number | Unix timestamp in seconds. Omit or pass -1 for a session cookie. |
httpOnly | boolean | Restrict cookie access to HTTP (not JavaScript). |
secure | boolean | Only send cookie over HTTPS. |
sameSite | "Strict" | "Lax" | "None" | Cross-site request policy. |
Clear cookies
context.clearCookies(options?) removes cookies. Called without arguments it clears everything in one atomic operation. Pass filter options to clear only matching cookies:
ClearCookieOptions accepts:
| Field | Type | Description |
|---|---|---|
name | string | RegExp | Match by cookie name. |
domain | string | RegExp | Match by cookie domain. |
path | string | RegExp | Match by cookie path. |
When you pass filter options, Handstage fetches all cookies, clears the entire cookie jar, and re-adds the ones that do not match your filter. This is necessary because the underlying CDP Storage domain does not support targeted deletes. The read-clear-rewrite sequence is performed atomically in terms of your Handstage code, but there is a brief window where all cookies are absent.
Extra HTTP headers
context.setExtraHTTPHeaders(headers) injects a fixed set of headers into every outgoing HTTP request made by any page in the context. This is the standard way to attach authentication tokens, API keys, or tracing headers: