Home › Web › Cookies
Web

Cookies

A cookie is a small piece of data a website stores in your browser and gets back on every later request. It is how a site remembers you between pages.

Why they exist

HTTP forgets you after every request. A cookie is how a site keeps you logged in: the server sets one, and the browser sends it back each time, so the site knows it is still you.

Setting one

The server sends a Set-Cookie header; the browser returns it in a Cookie header on later requests.

Set-Cookie: session=abc123; Max-Age=86400; Secure; HttpOnly; SameSite=Lax

Flags

Secure sends it only over HTTPS, HttpOnly hides it from JavaScript, and SameSite controls whether it is sent on requests from other sites. They matter for security.

Keep reading: SQL  ·  JSON  ·  APIs