Bokal › export cookies playwright

How to export a site's cookies as Playwright storageState

Log in once by hand in your browser, export the session, and drop it straight into your Playwright or Puppeteer suite — instead of scripting the login flow.

Last updated 26 August 2026. Competitor details below were verified against published manifests and repositories on that date.

The problem this solves. Scripting a login for tests is often the most brittle code in a suite: SSO redirects, MFA prompts, CAPTCHAs and rate limits all conspire against it. Authenticating once in a real browser and reusing the resulting cookies sidesteps all of that.

Steps

  1. Log in normally

    In Chrome, sign in to the site as you usually would. Complete any MFA. You want the browser holding a valid session.

  2. Open Bokal on that tab

    Click the Bokal toolbar icon. Grant access to that one site when prompted — Bokal asks only for the origin you are on.

  3. Export for automation

    In the toolbar, open the Export for… dropdown and choose Playwright storageState. Save the file as storageState.json next to your tests. The same dropdown also offers Playwright addCookies and Puppeteer setCookie.

  4. Point Playwright at it

    Load it per-context, or globally in your config.

Per test context

const context = await browser.newContext({
  storageState: 'storageState.json',
});
const page = await context.newPage();
await page.goto('https://example.com/dashboard'); // already signed in

For the whole project

// playwright.config.ts
export default defineConfig({
  use: { storageState: 'storageState.json' },
});

Puppeteer

Choose Puppeteer setCookie in the same dropdown, then:

const cookies = JSON.parse(fs.readFileSync('cookies.json', 'utf8'));
await page.setCookie(...cookies);
await page.goto('https://example.com/dashboard');

Two caveats, stated plainly. Bokal exports cookies only — the origins array in the generated storageState is empty, so localStorage and sessionStorage are not included. If your app keeps its auth token in localStorage rather than a cookie, this will not be enough on its own.

And an exported session file is a live credential. Anyone holding it can act as you on that site until it expires. Do not commit it to a repository, and prefer a throwaway test account over your own.

What the file looks like

Playwright's storageState format is an object with a cookies array and an origins array:

{
  "cookies": [
    {
      "name": "session",
      "value": "…",
      "domain": ".example.com",
      "path": "/",
      "expires": 1788000000,
      "httpOnly": true,
      "secure": true,
      "sameSite": "Lax"
    }
  ],
  "origins": []
}

Because Bokal can read and write HttpOnly cookies, session cookies that a document.cookie-based tool cannot see are included.

Other formats

Going the other way

Import works too: feed Bokal a storageState.json or a Playwright/Puppeteer cookie array and it will write those cookies into the live browser session. That is useful for debugging what your test framework actually produced, in a real browser, with real rendering.

Frequently asked

Does this include localStorage?

No. Bokal exports cookies only, so the origins array is empty. If your authentication lives in localStorage, you will need Playwright's own context.storageState() after a scripted login instead.

Will the exported session expire?

Yes, on whatever schedule the site sets. Session cookies with no expiry are exported with expires: -1. Re-export when your suite starts failing on authentication.

Is any of this sent anywhere?

No. Bokal has no server and free users make zero network calls. The export is generated locally and saved by your browser's normal download flow.

Try Bokal

Free and open source (GPL-3.0). No account, no telemetry, no install-time site access.