Files
obscura/docs/Persist-cookies-and-storage.md
SGavrl a727fe82ad Add GitBook-synced docs under docs/
Mirror the wiki content into a docs/ tree so GitBook Git Sync can connect to
this repo. Adds SUMMARY.md for the table of contents, .gitbook.yaml pointing
GitBook at docs/, and converts wiki page links to relative .md paths.
2026-06-06 09:04:30 +00:00

1.4 KiB

--storage-dir persists cookies and localStorage to disk so they survive across runs.

CLI

obscura fetch https://example.com --storage-dir ./obscura-data
obscura fetch https://example.com --storage-dir ./obscura-data

The second invocation starts with the cookies and localStorage left by the first.

Server

obscura serve --storage-dir ./obscura-data

All CDP sessions read and write to the same directory. Run separate obscura serve processes with different --storage-dir paths for isolated profiles.

Layout

Inside ./obscura-data:

  • cookies.json: cookie jar in a stable format with same_site, expires, http_only, secure.
  • localStorage/<origin>.json: one file per origin.

The format is stable. Inspect with jq:

jq '.[] | select(.domain == "example.com")' ./obscura-data/cookies.json

When state is written

  • On clean process exit (Ctrl-C, SIGTERM).
  • After every navigation completes (CDP Page.navigate).
  • Manually via CDP Network.setCookie and Network.deleteCookies.

Login once, scrape many

obscura serve --storage-dir ./session-1

Drive a login flow once via Puppeteer or Playwright. Stop the server. Subsequent runs against the same --storage-dir start logged in.

Multiple identities

obscura serve --port 9222 --storage-dir ./identity-a
obscura serve --port 9223 --storage-dir ./identity-b

Clear state

rm -rf ./obscura-data