setup-browser-cookies
Import cookies from your real Chromium browser into the headless browse session. Opens an interactive picker UI where you select which cookie domains to import. Use before QA testing authenticated pages. Use when asked to "import cookies", "login to the site", or "authenticate the browser".
Setup Browser Cookies
Import logged-in sessions from your real Chromium browser into the headless browse session.
CDP mode check
First, check if Playwright is already connected to the user's real browser via CDP (Chrome DevTools Protocol). If connected over CDP, tell the user "Not needed — you're connected to your real browser via CDP. Your cookies and sessions are already available." and stop. No cookie import needed.
How it works
- Launch a Playwright browser session
- Detect installed Chromium browsers and open the picker UI
- User selects which cookie domains to import from their real browser
- Cookies are decrypted and loaded into the Playwright
storageStatefile
Steps
1. Launch the browser session
Use Playwright to launch a browser session; cookie import should write to Playwright's storageState file.
2. Open the cookie picker
Run the cookie import tool to auto-detect installed Chromium browsers and open an interactive picker UI in your default browser where you can:
- Switch between installed browsers
- Search domains
- Click "+" to import a domain's cookies
- Click trash to remove imported cookies
Tell the user: "Cookie picker opened — select the domains you want to import in your browser, then tell me when you're done."
3. Direct import (alternative)
If the user specifies a domain directly (e.g., /setup-browser-cookies github.com), skip the UI and import cookies for that domain directly from the specified browser.
4. Verify
After the user confirms they're done, list the imported cookies and show the user a summary of imported cookies (domain counts).
Notes
- On macOS, the first import per browser may trigger a Keychain dialog — click "Allow" / "Always Allow"
- On Linux,
v11cookies may requiresecret-tool/libsecret access;v10cookies use Chromium's standard fallback key - Cookie picker is served on the same port as the browse server (no extra process)
- Only domain names and cookie counts are shown in the UI — no cookie values are exposed
- The browse session persists cookies between commands, so imported cookies work immediately