Skip to the content.

HTTP Cookie

Also called web cookie, browser cookie.

Use Case

Typically, an HTTP cookie is used to tell if two requests come from the same browser. It remembers stateful information for the stateless HTTP protocol.

Cookies are mainly used for three purposes:

Response

Set-Cookie: id=<uid>; Domain=<domain>
Set-Cookie: id=<uid>; Path=/path/to

Set-Cookie: id=a3fWa; Expires=Thu, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly; SameSite=Strict
Set-Cookie: id=a3fWa; Max-Age=300; Secure; HttpOnly; SameSite=Strict
Set-Cookie: id=a3fWa; Max-Age=300; Secure; HttpOnly; SameSite=Strict; csrftoken=xxxxxx

Request

Cookie: id=<uid>

See RFC 6265 - HTTP State Management Mechanism (2011.4) (Obsolete RFC 2109, RFC 2965).

Python Examples and Recipes

References