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.
Concurrency and recovery
Section titled “Concurrency and recovery”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.
Subcommands
Section titled “Subcommands”harn cookies list [--domain <d>] [--json] # list cookies, grouped by domainharn 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 everythingharn cookies header <url> # print a Cookie: header value for the URLharn cookies import <file> [--replace] # merge cookies from a JSON fileharn cookies export <file> # write the store to a fileharn cookies info [--json] # store path, size, counts, exporting toolOptions by subcommand
Section titled “Options by subcommand”list:--domain <domain>filters to one domain;--jsonfor 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:--replacereplaces the entire store instead of merging by(name, domain, path).
Examples
Section titled “Examples”# List everything in the default jar, grouped by domainharn cookies list
# List one domain as JSONharn cookies list --domain .example.com --json
# Set a secure session cookieharn cookies set session_id abc123 --domain .example.com --secure --httpOnly
# Emit a Cookie: header for use with another HTTP clientharn cookies header https://example.com/
# Drop cookies for one domain, or wipe the whole jarharn cookies clear --domain example.comharn cookies clear --all
# Move a jar between toolsharn cookies export /path/to/backup.jsonharn 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