Documentation Python quickstart Blog Free tools Enterprise solutions hello@quanticdata.ioLog in

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

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.
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.

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.

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.

  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.
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.

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.

AttributeSeen onWhat it does
Expires / Max-AgeGoogle (19 May 2027), Wikipedia (Max-Age=3600, one hour)When the cookie expires. Without either, it is a session cookie.
Domain.google.com, .wikipedia.orgSends the cookie to subdomains too. Without it, only to the exact host.
Path/ on all of themSends it for every path under the one given.
SecureAll of themOnly over HTTPS.
HttpOnlyGoogle AEC, Wikipedia WMF-Last-AccessScripts in the page cannot read it, which limits cookie theft through injected code.
SameSitelax on Google, None on WikipediaWhether the cookie goes along on requests started from other sites.

Cookies travel as ordinary headers, so everything in HTTP headers explained applies: Set-Cookie in responses, Cookie in requests.

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:

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:

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.

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:

RequestCookie the site receivedIP the site saw
Same session name that set the cookiesession_id=demo42x.x.x.x
Residential Basic, new session IDsession_id=demo42x.x.x.x
Mobile linesession_id=demo42x.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. When you want a new IP for every request, keep requests stateless and send no cookies; how to use rotating proxies covers that pattern.

  • 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.
  • Mobile: carrier IPs with the same session settings, for sites and apps that expect phone traffic. See mobile proxies.

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

Sources & further reading

FAQ

Quick answers on http cookies explained.

Something else? Ask us

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.

Related reading