browser_set_cookie
Set a cookie in the browser context with full control over all attributes. Supports domain, path, secure, httpOnly, sameSite, and expiration settings. Useful for injecting session tokens or test cookies.
When to use browser_set_cookie
Use browser_set_cookie when you need to read, set, or clear cookies to manage session state. It is part of Owl Browser's Cookie Management toolset and runs inside a self-hosted, source-level stealth engine, so every call inherits the same undetectable browser fingerprint as the rest of your automation — no separate anti-detect setup required.
Usage Example
Parameters
Required
context_idstringrequiredThe unique identifier of the browser context (e.g., 'ctx_000001')
urlstringrequiredURL to associate with the cookie for domain validation. The cookie's domain must match or be a parent of this URL's domain. Example: 'https://example.com'
namestringrequiredThe cookie name. Case-sensitive identifier for the cookie. Example: 'session_id', 'auth_token'
valuestringrequiredThe cookie value. Can be any string data. For security tokens, use the exact value from authentication
Optional
domainstringCookie domain scope. If empty, creates a host-only cookie. With leading dot (e.g., '.example.com'), the cookie is visible to all subdomains
pathstringURL path that must exist in the request URL for the cookie to be sent. Default: '/' (all paths). Example: '/api' restricts cookie to /api/* paths
securebooleanIf true, cookie is only sent over HTTPS connections. Set to true for sensitive cookies. Default: false
httpOnlybooleanIf true, cookie cannot be accessed via JavaScript (document.cookie). Protects against XSS. Default: false
sameSiteenumnonelaxstrictCross-site request restriction: 'strict' (only same-site), 'lax' (same-site + top-level navigation), 'none' (allow cross-site, requires secure=true). Default: 'lax'
expiresintegerUnix timestamp (seconds since epoch) when the cookie expires. Use -1 or omit for session cookie (deleted when browser closes). Example: 1735689600 for a future date
Response
Returns a JSON object with the operation result.
{
"success": true,
"result": <value>
}Frequently Asked Questions
What does browser_set_cookie do?
Set a cookie in the browser context with full control over all attributes. Supports domain, path, secure, httpOnly, sameSite, and expiration settings. Useful for injecting session tokens or test cookies. It belongs to Owl Browser's Cookie Management category and is available through the REST API, the Python SDK (browser.set_cookie()), the Node.js SDK, and the MCP server.
What parameters does browser_set_cookie accept?
browser_set_cookie accepts 4 required parameters (context_id, url, name, value) and 6 optional parameters. All parameters are sent as JSON in a POST request to /api/execute/browser_set_cookie.
Is browser_set_cookie detectable by anti-bot systems like Cloudflare or DataDome?
No. browser_set_cookie executes inside Owl Browser's Chromium engine, which applies fingerprint spoofing at the C++ source level rather than through JavaScript patches. Every tool call shares the same consistent, human-like fingerprint, so anti-bot systems such as Cloudflare, DataDome, and Akamai see an ordinary browser.
Related Tools
browser_get_cookiesRetrieve all cookies from the browser context with full details including httpOnly, secure, sameSite, domain, path, and expiration. Optionally filter by URL to get only relevant cookies.
browser_delete_cookiesDelete cookies from the browser context. Can delete all cookies, cookies for a specific URL, or a specific cookie by name. Useful for testing login flows or clearing session state.
browser_update_profile_cookiesUpdate the profile file with the current cookies from the browser. Call after login to persist session cookies. Only updates cookies, preserving other profile settings.
http_session_get_cookiesGet all cookies stored in a session. Optionally filter by URL to get only cookies that would be sent to a specific domain. Returns cookies as a JSON array with domain, name, value, path, expiry, secure, and httponly fields.
http_session_set_cookiesImport cookies into a session. Accepts either a JSON array of cookie objects with domain, name, value, path fields, or Netscape cookie format lines. Useful for importing cookies from browser contexts (browser_get_cookies) into HTTP sessions for non-DOM operations.
browser_create_contextCreate a new isolated browser context with its own cookies, storage, and optional proxy configuration. Each context acts as an independent browser session. Use this to create multiple isolated browsing sessions, configure proxy/Tor connections, load browser profiles with saved fingerprints, and enable/disable LLM features. Returns a context_id to use with other browser tools.