You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The file should contain a JSON array of cookie objects with name, value, and domain fields. Guide: [Cookie Management](https://botbrowser.io/docs/identity/cookie-management/)
213
+
Each cookie object must include a `url` field. Cookies without `url` are silently skipped. Guide: [Cookie Management](https://botbrowser.io/docs/identity/cookie-management/)
214
214
215
215
<aid="--bot-bookmarks"></a>
216
216
### `--bot-bookmarks`
@@ -512,7 +512,7 @@ chromium-browser \
512
512
--bot-profile="/absolute/path/to/profile.enc" \
513
513
--bot-config-browser-brand="chrome"\ # ENT Tier2 feature
@@ -56,36 +56,38 @@ The file should contain a JSON array of cookie objects.
56
56
57
57
2.**Cookie injection.** Cookies are injected into the browser's cookie store before any page navigation occurs. This means the first HTTP request already includes the injected cookies.
58
58
59
-
3.**Domain matching.** Each cookie must include a `domain` field. The browser only sends cookies to matching domains, following standard cookie rules.
59
+
3.**Domain matching.** Each cookie must include a `url` field. The browser uses it to set the cookie origin and only sends cookies to matching domains, following standard cookie rules.
60
60
61
61
### Cookie Format
62
62
63
63
Each cookie object supports these fields:
64
64
65
65
| Field | Required | Description |
66
66
|-------|----------|-------------|
67
+
|`url`| Yes | Full URL used to set the cookie (e.g., `https://example.com`). Required for the cookie to be accepted. |
67
68
|`name`| Yes | Cookie name. |
68
69
|`value`| Yes | Cookie value. |
69
-
|`domain`|Yes| Domain the cookie belongs to. Prefix with `.` for subdomains (e.g., `.example.com`). |
70
+
|`domain`|No| Domain the cookie belongs to. Prefix with `.` for subdomains (e.g., `.example.com`). |
70
71
|`path`| No | Cookie path. Defaults to `/`. |
71
-
|`secure`| No | Whether the cookie requires HTTPS. Defaults to `false`. |
72
+
|`secure`| No | Whether the cookie requires HTTPS. Defaults to `true`. |
72
73
|`httpOnly`| No | Whether the cookie is HTTP-only (not accessible via JavaScript). Defaults to `false`. |
73
-
|`sameSite`| No | SameSite attribute: `Strict`, `Lax`, or `None`. |
74
-
|`expires`| No | Expiration time as a Unix timestamp (seconds since epoch). |
74
+
|`sameSite`| No | SameSite attribute: `strict`, `lax`, or `none`. |
75
+
|`expirationDate`| No | Expiration time as a Unix timestamp (seconds since epoch). |
75
76
76
77
---
77
78
78
79
<aid="common-scenarios"></a>
79
80
80
81
## Common Scenarios
81
82
82
-
### Pre-authenticated session
83
+
### Pre-authenticated session (Playwright)
83
84
84
85
```javascript
85
86
import { chromium } from"playwright-core";
86
87
87
88
constcookies=JSON.stringify([
88
89
{
90
+
url:"https://example.com",
89
91
name:"session_id",
90
92
value:"abc123def456",
91
93
domain:".example.com",
@@ -94,6 +96,7 @@ const cookies = JSON.stringify([
94
96
httpOnly:true,
95
97
},
96
98
{
99
+
url:"https://example.com",
97
100
name:"user_prefs",
98
101
value:"theme=dark",
99
102
domain:".example.com",
@@ -115,16 +118,55 @@ await page.goto("https://example.com/dashboard"); // Loads as authenticated user
115
118
awaitbrowser.close();
116
119
```
117
120
121
+
### Pre-authenticated session (Puppeteer)
122
+
123
+
With Puppeteer, use `browser.defaultBrowserContext()` to access the context that `--bot-cookies` injects into. `context.cookies()` returns all cookies for the context without a URL argument.
| Cookies not injected (silently skipped) | Each cookie object must include a `url` field (e.g., `"url": "https://example.com"`). Without it, the cookie is silently dropped. |
238
+
| Puppeteer: `context.cookies()` returns empty | Use `browser.defaultBrowserContext()`. Cookies from `--bot-cookies` are injected into the default context only, not into contexts created with `browser.createBrowserContext()`. |
193
239
| Cookies not sent with requests | Verify the `domain` field matches the target site. Use `.example.com` (with leading dot) to include subdomains. |
194
240
| "Invalid JSON" error | Check that the cookie value is a valid JSON array. Use a JSON validator if needed. |
195
241
| File not found | When using `@/path/to/file.json`, ensure the path is absolute. |
0 commit comments