Skip to content
BENIBIX Learn

HTTP Cookie

Development🌐 Web DevelopmentBrowser Code

Also known as Cookie, Browser Cookie, Web Cookie, Set-Cookie, HttpOnly

A small piece of text a site stores in your browser, sent back on each visit.

Think of it like

Think of it like a cloakroom ticket. You show it each time you come back, so they know which coat is yours.

Example

Jack logs into a shop. The site sets a cookie with his session id, so the next page knows who he is.

Why it matters

Cookies are how websites remember you between pages. Logins depend on them.

Definition

A cookie is a small piece of text a website asks the browser to keep. The browser sends it back with every later request to that site. That is how a site remembers you are logged in or what is in your cart. A cookie can be set to expire, and flags like HttpOnly and Secure keep it safer. Cookies used to track people across sites are why many countries require a cookie notice.

Example code

http
Set-Cookie: session=abc123; HttpOnly; Secure; Max-Age=3600
A login cookie that scripts cannot read and that lasts one hour.

Common mistake

Storing a login cookie without HttpOnly. Then a script injected into the page can steal it.

Key takeaways

  1. 1
    Kept by the browser. Sent back on every request.
  2. 2
    Remembers you. Logins, carts and settings.
  3. 3
    Lock it down. Use HttpOnly and Secure.

Compare

Learn it properly