One place I use browser cookies is my private media archive. I paste a YouTube or X video link, and a background service downloads it, transcribes it, and makes it searchable. Some downloads need a signed-in account. Being logged into Brave on my Mac doesn't automatically log the downloader into the same account.

The downloader can reuse that login through cookies. But those cookies need to reach the service, and when the session expires, downloads can stop working. I wanted to keep the login available without having to browse the sites and export cookies myself.

So I built a small Bun + Playwright app and left it running on a spare Mac. Every 15 minutes, it visits the selected sites in a background browser and syncs the resulting cookies to the private services that need them.

Xiaohei rides a clock hand to revisit YouTube and X and sync their cookies

The setup starts with a normal login in Brave. I choose the profile I want to use and the sites I want to sync, currently YouTube and X. The app remembers that selection, even if I use a different profile for browsing. For agents to have their own identity, they need dedicated accounts too. A separate browser profile still uses whichever accounts are signed into it.

I then import the selected cookies into the app. It keeps its own persistent Brave session, which means it remembers the login between runs. That session is what Playwright uses for the scheduled visits. I only need to import again if I change the selected profile or sites, or need to replace the login.

During each run, the app opens the sites without showing a browser window, waits for them to load, and collects their cookies. The visits give the websites a chance to renew the session. Whether they actually do is up to each site, so this doesn't make the login permanent or remove the possibility of signing in again.

The cookies then go to a receiver in my backend. Its job is to keep the latest set available for the tools that need them. Each successful sync replaces the previous copy, so a service can pick up the latest cookies when it starts a job.

To connect the Mac to that receiver, I generate a pairing token in the backend and enter it in the app alongside the service's address. The token gives the Mac permission to upload cookies. The app keeps it in macOS Keychain, and the receiver checks it before accepting each sync.

My media archive is one consumer of those cookies. Its downloader loads them when it needs a signed-in session. Other services can use the same approach, whether they're downloading something or opening a page in an automated browser.

For an agent, there are two ways this can work. In my current setup, the agent asks a private service to do a job, and the service handles the cookies. The agent doesn't need to manage the login itself.

An agent running its own tools would need to retrieve the cookies directly. The backend could give each agent a separate access token, limited to the accounts and sites it needs. The agent could then fetch the latest cookies with curl and load them into its own browser or downloader. That token would be separate from the Mac's pairing token, so I could turn off an agent's access to the receiver without stopping the uploads.

I haven't needed to add direct retrieval yet. My data scraping runs through headless Codex, so I only need to sync the cookies to its control service. That service also syncs the Codex OAuth credentials.

A macOS background task keeps the sync running every 15 minutes. I leave the spare Mac awake and online, without browsing those sites myself. If a site logs the account out, I'd use Screen Sharing to access the Mac, sign back in through the selected Brave profile, and import its cookies again. I haven't needed to do that yet.