> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cookie sync

> Sync local Chrome cookies to a Browserbase persistent context so your browser agent can work with authenticated websites.

The `cookie-sync` skill copies cookies from your local Chrome into a [Browserbase context](/platform/browser/core-features/contexts). Your browser agent can reuse that context across cloud sessions instead of repeating a login flow on every run.

Use it when you're already signed in locally and want your agent to access the same site on Browserbase. You can filter cookies by domain and refresh an existing context when cookies expire.

## Install

You need Node.js 22+, a Chromium-based browser with remote debugging enabled and at least one open tab, and `BROWSERBASE_API_KEY` in your environment.

```bash theme={null}
npx skills add browserbase/skills --skill cookie-sync
npm install -g browse
```

Select your coding agent in the installer. Then ask your agent to run `npm install` in the installed `cookie-sync` directory to set up its script dependencies.

## Sync an authenticated session

Sign in to the target site in the Chrome profile that exposes the debugging endpoint. If you launch Chrome with a separate `--user-data-dir`, sign in inside that profile first. Set `CDP_URL` if the skill can't discover your debugging endpoint.

Replace `app.example.com` with your site's domain, then give your agent this prompt:

```text theme={null}
Use cookie-sync to copy only app.example.com cookies from my local Chrome
to a Browserbase context. Create a browser session with that context,
open https://app.example.com, and verify that I'm signed in.
Save the context ID for reuse, then release the cloud session.
```

Your agent filters the cookies, creates or updates a context, and returns its ID. It then creates a session with that context and attaches the Browse CLI to the session's `connectUrl`.

<Note>
  Cookie sync transfers cookies, not your entire browser profile. A site may
  require a fresh login or additional authentication state. Verify access before
  using the context in a scheduled job.
</Note>

## Refresh cookies

When a site signs you out, sign in locally again and ask your agent to refresh the same context:

```text theme={null}
Use cookie-sync to refresh my existing Browserbase context with ID
<context-id>, filtering to app.example.com. Verify that a new session
using the context can access the site, then release the session.
```

The script accepts `--domains` for a comma-separated domain filter and `--context` for an existing context ID. Domain filters include subdomains. Later cloud sessions can reuse the context without your local Chrome running.

## Troubleshooting

* **No DevTools endpoint:** enable remote debugging in your Chromium browser and point `CDP_URL` at its debugging endpoint.
* **No open page targets:** open a tab in that browser profile.
* **The site still requests a login:** confirm that the local profile has valid cookies for the target domain, then refresh the context. Cookie sync doesn't guarantee that a site will accept the session.

## Further reading

<CardGroup cols={2}>
  <Card title="Persistent contexts" icon="fingerprint" href="/platform/browser/core-features/contexts">
    Reuse cookies and browser state across sessions.
  </Card>

  <Card title="Skill source" icon="github" href="https://github.com/browserbase/skills/tree/main/skills/cookie-sync">
    View script options and browser setup instructions.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.