# HTTP Cookies Explained: Set-Cookie, Sessions

> HTTP cookies explained with real requests: Set-Cookie and Cookie headers, attributes like HttpOnly and SameSite, cookie jars in curl and Python, and proxies.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / HTTP Cookies Explained: Set-Cookie, Sessions

# HTTP cookies explained: Set-Cookie, the Cookie header and sessions

Proxies · Nov 20, 2026 · 5 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![How an HTTP cookie travels: the server answers with Set-Cookie session_id=demo42, the client keeps it in a cookie jar and sends it back in the Cookie header; in our test the same cookie went out from three proxy IPs: the residential session that set it, a new residential session and a mobile line; the card lists the attributes Secure, HttpOnly and SameSite=lax.](https://quanticdata.io/blog/http-cookies-explained/hero.webp?v=20261120h)

On this page

- [How a cookie works, in one round trip](https://quanticdata.io/blog/http-cookies-explained/#how-a-cookie-works-in-one-round-trip)
- [Real Set-Cookie lines from two large sites](https://quanticdata.io/blog/http-cookies-explained/#real-set-cookie-lines-from-two-large-sites)
- [Cookie attributes, read from those lines](https://quanticdata.io/blog/http-cookies-explained/#cookie-attributes-read-from-those-lines)
- [Sending a cookie by hand](https://quanticdata.io/blog/http-cookies-explained/#sending-a-cookie-by-hand)
- [Cookies and sessions in Python](https://quanticdata.io/blog/http-cookies-explained/#cookies-and-sessions-in-python)
- [One cookie, three IPs: what the site sees](https://quanticdata.io/blog/http-cookies-explained/#one-cookie-three-ips-what-the-site-sees)
- [Which proxy for cookie-based sessions](https://quanticdata.io/blog/http-cookies-explained/#which-proxy-for-cookie-based-sessions)

An HTTP cookie is a small name=value pair that a server sends in a `Set-Cookie` response header. The browser or client stores it and sends it back in the `Cookie` request header on later requests to the same site. That is how a stateless protocol remembers a login, a cart or a language choice.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=http-cookies-explained) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

We tested every step on 20 November 2026 with curl 8.21.0 and Python Requests 2.34.2, through QuanticData residential and mobile proxies: we created a cookie, stored it, sent it back from three different IPs, and read the real cookies of two large sites. Exit IPs are masked.

## How a cookie works, in one round trip

1. **The server sets it.** httpbin.org/cookies/set?session_id=demo42 answered with a redirect and this header: `set-cookie: session_id=demo42; Secure; Path=/`.
2. **The client stores it.** A browser keeps it in its cookie store; curl keeps it in a cookie jar file when you pass `-c jar.txt`.
3. **The client sends it back.** On the next request to the same site and path, the header `Cookie: session_id=demo42` goes out with it (`-b jar.txt` in curl).
4. **The server reads it** and knows the request belongs to the same visitor or session.

```bash
curl -x http://USER:PASS@residentialboson.quanticdata.io:10000 -i -c jar.txt \
  "https://httpbin.org/cookies/set?session_id=demo42"
HTTP/1.1 302 Found
location: /cookies
set-cookie: session_id=demo42; Secure; Path=/

type jar.txt
# Netscape HTTP Cookie File
httpbin.org	FALSE	/	TRUE	0	session_id	demo42
```

The jar line reads: site, subdomains, path, Secure, expiry (0 means a session cookie, gone when the client closes), name, value.

## Real Set-Cookie lines from two large sites

Through a Residential Premium line in Germany, www.google.com set this cookie on a plain request for its home page:

```
Set-Cookie: AEC=...; expires=Wed, 19-May-2027 15:33:05 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax
```

Through a Residential Basic line in the US, www.wikipedia.org set four, among them:

```
set-cookie: WMF-Last-Access=20-Nov-2026;Path=/;HttpOnly;secure;Expires=Tue, 22 Dec 2026 12:00:00 GMT
set-cookie: GeoIP=US:AL:Mobile:...; Path=/; secure; Domain=.wikipedia.org
set-cookie: NetworkProbeLimit=0.001;Path=/;Secure;SameSite=None;Max-Age=3600
```

The `GeoIP` cookie is worth a look: Wikipedia stored where it placed our exit IP, Mobile, Alabama. A cookie can carry what a site concluded about your IP to every later request.

## Cookie attributes, read from those lines

| Attribute | Seen on | What it does |
| --- | --- | --- |
| `Expires` / `Max-Age` | Google (19 May 2027), Wikipedia (Max-Age=3600, one hour) | When the cookie expires. Without either, it is a session cookie. |
| `Domain` | `.google.com`, `.wikipedia.org` | Sends the cookie to subdomains too. Without it, only to the exact host. |
| `Path` | `/` on all of them | Sends it for every path under the one given. |
| `Secure` | All of them | Only over HTTPS. |
| `HttpOnly` | Google AEC, Wikipedia WMF-Last-Access | Scripts in the page cannot read it, which limits cookie theft through injected code. |
| `SameSite` | `lax` on Google, `None` on Wikipedia | Whether the cookie goes along on requests started from other sites. |

Cookies travel as ordinary headers, so everything in [HTTP headers explained](https://quanticdata.io/blog/http-headers-explained/) applies: `Set-Cookie` in responses, `Cookie` in requests.

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=http-cookies-explained) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Sending a cookie by hand

You do not need a jar to send a cookie you already have, for example one copied from your browser's developer tools. In curl, give `-b` the pairs themselves instead of a file name; several cookies go in one string, separated by semicolons. Through a Residential Premium line in Germany:

```bash
curl -x http://USER:PASS@residentialpremium.quanticdata.io:8080 \
  -b "session_id=demo42; lang=de" https://httpbin.org/cookies
{
  "cookies": {
    "lang": "de",
    "session_id": "demo42"
  }
}
```

The server received both cookies in one `Cookie` header. Only the name and value travel back: attributes such as Secure or Expires stay with the client, which uses them to decide whether to send the cookie at all. A cookie copied from a logged-in browser carries that login, so treat it like a password.

## Cookies and sessions in Python

In Python Requests, a `Session` is a cookie jar: it stores every Set-Cookie and sends the cookies back on the next call. We ran it through a mobile line:

```python
import requests
s = requests.Session()
s.proxies = {"https": "http://USER:PASS@mobile.quanticdata.io:8080"}
s.get("https://httpbin.org/cookies/set?session_id=demo42", allow_redirects=False)
print(s.cookies.get_dict())        # {'session_id': 'demo42'}
r = s.get("https://httpbin.org/anything").json()
print(r["headers"]["Cookie"])      # session_id=demo42
```

Plain `requests.get()` calls do not share cookies; use a Session whenever a site sets one you need to keep. Proxy setup for Requests is in [a proxy in Python Requests](https://quanticdata.io/blog/how-to-use-a-proxy-with-python-requests/).

## One cookie, three IPs: what the site sees

Here is the part that matters with proxies. We sent the same jar to httpbin.org/anything, which echoes the cookie and the IP it came from, three times:

| Request | Cookie the site received | IP the site saw |
| --- | --- | --- |
| Same session name that set the cookie | session_id=demo42 | x.x.x.x |
| Residential Basic, new session ID | session_id=demo42 | x.x.x.x |
| Mobile line | session_id=demo42 | x.x.x.x |

To the site, that is one session arriving from three addresses within seconds. A site can ask a session that changes IP to log in again. The session name is a setting in the proxy username: use one session name per cookie jar, and start a fresh jar when you change it. For one IP kept for 30 days, use [static residential proxies](https://quanticdata.io/static-residential-proxies/). When you want a new IP for every request, keep requests stateless and send no cookies; [how to use rotating proxies](https://quanticdata.io/blog/how-to-use-rotating-proxies/) covers that pattern.

## Which proxy for cookie-based sessions

- **Residential Basic and Premium:** home IPs in the country you pick, with the session name and session time set in the username, for logins, carts and multi-page flows. See [residential proxies](https://quanticdata.io/residential-proxies/).
- **Mobile:** carrier IPs with the same session settings, for sites and apps that expect phone traffic. See [mobile proxies](https://quanticdata.io/mobile-proxies/).

Cookies are one of the ways a site recognises a returning visitor; [browser fingerprinting](https://quanticdata.io/blog/how-to-browser-fingerprint/) is another, and works without any cookie. To try it on a residential line, there is a [Residential Basic free trial](https://quanticdata.io/residential-proxy-free-trial/); the command-line options are in [how to use a proxy with curl](https://quanticdata.io/blog/how-to-use-a-proxy-with-curl/).

### Sources & further reading

- [RFC 6265: HTTP State Management Mechanism](https://www.rfc-editor.org/rfc/rfc6265)
- [MDN: Using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies)
- [curl: HTTP cookies](https://curl.se/docs/http-cookies.html)
- [Requests: Session objects](https://requests.readthedocs.io/en/latest/user/advanced/#session-objects)

## FAQ

Quick answers on http cookies explained.

[Something else? Ask us](mailto:hello@quanticdata.io)

### What are HTTP cookies?

Small name=value pairs a server sends in a Set-Cookie header. The client stores them and sends them back in the Cookie header on later requests to the same site, so the site can recognise the session.

### What is the difference between Set-Cookie and Cookie?

`Set-Cookie` is a response header: the server creates or updates a cookie, with attributes. `Cookie` is a request header: the client sends back the name=value pairs it holds for that site, without the attributes.

### What does HttpOnly mean on a cookie?

Scripts running in the page cannot read the cookie; it is only sent with HTTP requests. Google set its AEC cookie with HttpOnly, Secure and SameSite=lax in our test.

### What is a cookie jar?

The store where a client keeps cookies between requests. In curl, `-c jar.txt` writes it and `-b jar.txt` sends it; in Python Requests, a `Session` keeps one in memory.

### Should one cookie session use one proxy session?

Yes. In our test the same cookie reached the site from three IPs on two networks within seconds, so the site saw one session from three addresses. Use one session name per cookie jar and start a new jar when you change it.

### What is a session cookie?

A cookie with no Expires or Max-Age: it lasts until the browser or client closes. httpbin.org's session_id=demo42 was one, shown with expiry 0 in curl's jar.

## Session names for cookie-based work

Residential and mobile proxies with a session name you set per task.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=http-cookies-explained) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Related reading

- [HTTP vs HTTPS: What a Proxy Sees in Each](https://quanticdata.io/blog/http-vs-https-proxy/): Proxies · HTTP sends requests as plain text; HTTPS wraps the same requests in TLS. We put a logging relay in front of a residential proxy line on 20 November 2026 and captured both: 340 readable bytes for http://, and for https:// one CONNECT line followed by 803 encrypted bytes.
- [Change Proxy IP by Link: Rotation Links](https://quanticdata.io/blog/change-proxy-ip-by-link/): Proxies · A rotation link is a URL that restarts one sticky session: open it and the session starts again; in our test of 20 November 2026 each of three calls was followed by a new exit IP. Below: the API call that creates the link, what it answered, the 10-second pause between rotations, and what to do on Mobile and Residential Premium.
- [ISP Proxy API: Stock, Quote and Buy by Code](https://quanticdata.io/blog/isp-proxy-api/): Proxies · The Premium ISP endpoints let a script do what the configurator does: read the catalog with live stock, pick a pool or a city and carrier, get a server-side quote and buy from the balance. Below: each call with the answer we got on 20 November 2026, what "currently unavailable" means, and how to write a buyer that never pays twice.

---

Source: https://quanticdata.io/blog/http-cookies-explained/ · Site index for AI: https://quanticdata.io/llms.txt
