---
title: "What is a cookie jar in HTTP clients?"
url: https://proxy.wiki/glossary/cookie-jar/
type: Glossary Term
author: "proxy.wiki editorial"
published: 2026-09-06
updated: 2026-10-21
site: proxy.wiki
topics: ["Proxy fundamentals"]
license: CC BY 4.0; quote freely with attribution to https://proxy.wiki/
---

# What is a cookie jar in HTTP clients?

> A cookie jar is the store a client keeps of the cookies it has received, keyed by domain and path, and replayed on later requests that match.

In scraping, the cookie jar can identify you more firmly than the exit address does. A session cookie is a token the server issued to one client, so carrying it across a [rotating proxy](/glossary/rotating-proxy/) tells the target that a single client is hopping between addresses, which is more distinctive than staying on one would have been. Rotation and shared state work against each other, and the jar is where they meet.

## What a jar looks like on disk

curl stores its jar in the Netscape cookie-file format, which many other tools read. A local test server set two cookies, one with `HttpOnly` and no expiry, one with `Secure` and `Max-Age=86400`, and curl 8.7.1 wrote this file (tabs shown as `<TAB>`):

```
$ curl -s -c jar.txt -o /dev/null http://localhost:38473/set
$ cat jar.txt
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

localhost<TAB>FALSE<TAB>/<TAB>TRUE<TAB>1792697167<TAB>pref<TAB>dark
#HttpOnly_localhost<TAB>FALSE<TAB>/<TAB>FALSE<TAB>0<TAB>sid<TAB>a1b2c3
```

Each cookie line has seven fields, in the order curl’s documentation gives:

| Field | Meaning | pref line | sid line |
| --- | --- | --- | --- |
| 1 | Domain, prefixed #HttpOnly_ when the cookie is HttpOnly | localhost | #HttpOnly_localhost |
| 2 | Include subdomains | FALSE | FALSE |
| 3 | Path | / | / |
| 4 | Send over HTTPS only (the Secure attribute) | TRUE | FALSE |
| 5 | Expiry in Unix seconds; 0 for a session cookie | 1792697167 | 0 |
| 6 | Name | pref | sid |
| 7 | Value | dark | a1b2c3 |

Two details in that file cause real bugs. The `#HttpOnly_` prefix makes an ordinary cookie look like a comment, so a hand-written parser that skips lines starting with `#` silently drops every HttpOnly cookie, including the session cookie in this example. And the session cookie has an expiry of `0`, which a loader has to read as “ends with the session” rather than “expired in 1970”.

Python shows what happens next. On Python 3.15.0, `http.cookiejar.MozillaCookieJar` handles the prefix correctly, but it treats a session cookie as discardable and loads it only when told to keep those:

```
>>> j = http.cookiejar.MozillaCookieJar("jar.txt"); j.load()
>>> sorted(c.name for c in j)
['pref']
>>> j = http.cookiejar.MozillaCookieJar("jar.txt"); j.load(ignore_discard=True, ignore_expires=True)
>>> sorted(c.name for c in j)
['pref', 'sid']
```

The default call kept the preference and lost `sid`, the one cookie that carried the session. Nothing raised an error. Saving has the same default: the Python documentation notes that `save()` does not write session cookies unless `ignore_discard` is true. Replaying the jar with `curl -b jar.txt` sent `Cookie: pref=dark; sid=a1b2c3`, so a hand-off from curl to Python, or back, is a place where a session ends without anyone noticing.

Captured on 21 October 2026 against a local Python HTTP server on `localhost`, with curl 8.7.1 and Python 3.15.0 on macOS 26.6.2. The expiry value is the time of the test plus the server’s `Max-Age`.

## One jar per identity

The rule that follows is short: a jar is created with an identity, destroyed with it, and never shared between two. If you want a [sticky session](/glossary/sticky-session/), pin the jar and the exit together, so that a rotation also starts a fresh jar. A client that keeps one default jar for the whole process merges identities the moment you run two in parallel, and that mistake produces no error either. The [rotation guide](/guides/rotating-vs-sticky-sessions/#what-one-session-means-to-the-server) explains what the server counts as one session, the [curl guide](/guides/how-to-use-a-proxy-with-curl/#sessions-from-the-command-line) shows the jar and the session token handled together from the command line, and the [Python guide](/guides/proxies-in-python-requests-httpx/#keeping-a-session-on-one-address) does the same with a client object per identity.

## What emptying the jar does not reset

Emptying the jar removes one signal and leaves the others. The exit address, the TLS handshake, HTTP/2 behaviour, other browser storage and script-visible properties are untouched, and a target correlating on any of them links the new jar to the old one. A [headless browser](/glossary/headless-browser/) also keeps state in local storage, IndexedDB and its cache, none of which lives in the cookie jar.

## Frequently asked questions

### Should each proxy identity have its own cookie jar?

Yes. A session cookie reused across exit addresses tells the target that one client is moving between them. Create the jar when you create the identity, delete it when the identity is retired, and never let two identities share a process-wide default jar.

### How many cookies can a jar hold?

RFC 6265 sets floors rather than limits: user agents should support at least 4096 bytes per cookie, at least 50 cookies per domain and at least 3000 cookies in total. Real clients allow more and differ from one another, so do not design against the minimum figures.

### Does clearing cookies reset my identity on a website?

It removes one signal. The exit address, the TLS handshake, HTTP/2 behaviour, other browser storage and script-visible properties all stay the same, and a site correlating on any of them can link the new, empty jar to the old one on the first request.

## Sources

1. [RFC 6265: HTTP State Management Mechanism, cookie attributes, matching rules and minimum capacities](https://www.rfc-editor.org/rfc/rfc6265.html)
2. [curl documentation: HTTP cookies, the cookie file format, -b and -c](https://curl.se/docs/http-cookies.html)
3. [Python documentation: http.cookiejar, MozillaCookieJar and ignore_discard](https://docs.python.org/3/library/http.cookiejar.html)
