Skip to content

harn cookies

harn cookies [--store <path>] <subcommand> [options]

Manages the shared browser cookie store at ~/.cache/harnery/cookies.json. The format is CDP-native, so the same jar is read and written by harn browse, harn browse-ai, and harn fetch, and it round-trips cleanly with Playwright and agent-browser. Use it to inspect what’s stored, set a cookie by hand, produce a Cookie: header for another tool, or move a jar between tools.

Running harn cookies with no subcommand lists the store (same as harn cookies list). Use --store <path> for a separate jar (e.g. one per environment); it goes before the subcommand.

The default jar is safe to share across concurrent browse, browse-ai, and fetch processes. Updates take a short interprocess lock, merge while holding that lock, and atomically replace the completed JSON file. A process that cannot acquire the lock within 10 seconds stops with the exact .lock path instead of writing without coordination.

Reads verify that the file stayed unchanged while it was read. If stable content is malformed, the command identifies cookie-store parsing as the failed stage, prints the exact store path, and leaves the original file untouched. Copy that file before repairing it or restoring a known-good export. Do not delete or rename the store merely because parsing failed, and do not remove its .lock file while another browser process may still be running.

harn cookies list [--domain <d>] [--json] # list cookies, grouped by domain
harn cookies set <name> <value> --domain <d> # set a cookie (creates the file if missing)
harn cookies clear (--domain <d> | --all) # remove matching cookies, or wipe everything
harn cookies header <url> # print a Cookie: header value for the URL
harn cookies import <file> [--replace] # merge cookies from a JSON file
harn cookies export <file> # write the store to a file
harn cookies info [--json] # store path, size, counts, exporting tool
  • list: --domain <domain> filters to one domain; --json for machine output.
  • set: --domain <domain> is required (e.g. .example.com). Also --path <path> (default /), --secure, --httpOnly, --sameSite <Strict|Lax|None>, --expires <unix-seconds> (omit for a session cookie).
  • clear: one of --domain <domain> (drop cookies for a single domain) or --all (wipe cookies + origins) is required.
  • import: --replace replaces the entire store instead of merging by (name, domain, path).
Terminal window
# List everything in the default jar, grouped by domain
harn cookies list
# List one domain as JSON
harn cookies list --domain .example.com --json
# Set a secure session cookie
harn cookies set session_id abc123 --domain .example.com --secure --httpOnly
# Emit a Cookie: header for use with another HTTP client
harn cookies header https://example.com/
# Drop cookies for one domain, or wipe the whole jar
harn cookies clear --domain example.com
harn cookies clear --all
# Move a jar between tools
harn cookies export /path/to/backup.json
harn cookies import /path/to/backup.json --replace
# Operate on a separate jar (--store goes before the subcommand)
harn cookies --store /path/to/other.json info