Cookies and sessions
A site remembers who you are with a small code the browser keeps and sends back. Testers check that the code is set, kept, refused when wrong and removed at sign-out.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a cloakroom ticket. You hand in your coat and get a small ticket. The ticket contains only a reference number, but possession of that number can still give access to your coat, and the staff use the number to find your coat on the rail.
Daily List is a to-do list app. When Lily signs in, the server makes a record of her visit and hands her browser a ticket. The ticket is a cookie, a small piece of data that a site stores in the browser. The number on it is the , a code that links Lily's requests to her one signed-in visit.
From then on the browser sends the cookie on requests that match its domain, path, security and browser policy conditions. The server reads the number, finds Lily's record and knows who is asking. Lily does not have to type her password again on each page.
Tom, the tester, deletes the cookie in his browser's tools and refreshes the page, and Daily List asks him to sign in again. That supports the cookie-based design described here; the observation alone does not rule out other sign-in mechanisms or prove server-side revocation.
The picture has a limit. A cloakroom attendant sees your face as well as the ticket. A server sees only the ticket, so anyone who holds a copy of it can look like you. That is why the ticket needs care.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 2 in this section
- cloakroom
- a room where coats and bags are left safely
- revocation
- the act of officially withdrawing something given earlier
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Checking how a site remembers a visit: the ticket is set, kept, refused when wrong and removed at sign-out.
- Set at sign-in
- Kept while signed in
- Refused when wrong
- Removed at sign-out
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Cloakroom ticket | Cookie |
| The number on the ticket | Session identifier |
| The coat on the rail | The visit's details on the server |
| A drawer of your own | Local storage |
WHERE THIS PICTURE STOPS
- The attendant sees your face as well as the ticket. A server sees only the ticket.
- A coat stays on the rail. A visit ends and its details are removed.
- A ticket cannot be guessed at random. A weak code can be.
HOOK
Set, kept, wrong, removed.
REMEMBER IT THIS WAY
A contrast: two neighbours told apart by one test.
The cookie is the ticket, not the coat, and its opaque reference is still secret. Removing this browser copy does not prove that the server revoked a copied identifier.
| In the trick | What it stands for |
|---|---|
| the ticket | This opaque-ID cookie holds a secret session reference |
| the coat | The server finds the record of the visit |
TELL A FRIEND
A cloakroom ticket carries a reference, but a copy may still claim the coat. This opaque session cookie carries a secret identifier that lets the server find the visit.
OFTEN MIXED UP WITH Reading the network tab. The network tab lesson shows requests and headers. This lesson reads the cookie that travels in them.
PRACTISE AND KEEP
Sources for this topic — 9 sources
- Market practice
Using HyperText Transfer Protocol (HTTP) cookies (Mozilla developer docs) ↗ — Mozilla (developer documentation) · After sign-in the server sets a cookie holding a session identifier and the browser sends it back with later requests; a cookie with no expiry is a session cookie; setting the expiry in the past removes a cookie; a new session cookie should be sent at sign-in to stop session fixation (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Session management cheat sheet (Open Worldwide Application Security Project) ↗ — Open Worldwide Application Security Project (OWASP) · The session identifier must be renewed after any change in privilege such as sign-in, and the old one destroyed, which prevents session fixation (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Verification supplement, 6 November 2026: Actual introduction/session-ID properties opened: authenticated session identifier is itself a secret capable of impersonation; opaque does not mean secret-free.
- Market practice
Testing for cookies attributes (Open Worldwide Application Security Project Web Security Testing Guide) ↗ — Open Worldwide Application Security Project (OWASP) · Session cookies should carry the Secure and HttpOnly attributes, and a tester can check them in the browser's cookie view or with an intercepting proxy (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Window: localStorage property (Mozilla developer docs, Web APIs) ↗ — Mozilla (developer documentation) · Local storage keeps key and value pairs for a site, has no expiry time, survives closing the browser and stores only strings (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Insufficient session expiration (Open Worldwide Application Security Project Periodic Table of Vulnerabilities) ↗ — Open Worldwide Application Security Project (OWASP) · Insufficient session expiration: a session that stays valid too long, or after logout, lets someone reuse it (registry entry)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Archived wiki page. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Session management cheat sheet (Open Worldwide Application Security Project) ↗ — Open Worldwide Application Security Project (OWASP) · Session-ID properties and introduction: session identifier is a secret capable of impersonation; logout revocation and cached disclosure require distinct observations (actual relevant primary passages opened 6 November 2026).
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Verification supplement, 6 November 2026: Actual introduction/session-ID properties opened: authenticated session identifier is itself a secret capable of impersonation; opaque does not mean secret-free.
- Market practice
Using HyperText Transfer Protocol (HTTP) cookies (Mozilla developer docs) ↗ — Mozilla (developer documentation) · Complete substantive cookie article read7November2026 (live page modified17September2026): scoped sending, expiration/session restore, matching deletion, attributes. Browser lifetime differs from server session validity; not binding legal guidance.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Session management cheat sheet (Open Worldwide Application Security Project) ↗ — Open Worldwide Application Security Project (OWASP) · Complete Introduction, Session ID Content, Renew Session ID After Any Privilege Level Change, Session Expiration with all subsections and Limits of Logout on Browser Close, actually read7November2026. ID is secret; revoke session IDs server-side; distinguish cached display and continuing access.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Verification supplement, 6 November 2026: Actual introduction/session-ID properties opened: authenticated session identifier is itself a secret capable of impersonation; opaque does not mean secret-free.
- Market practice
Window: localStorage property (Mozilla developer docs, Web APIs) ↗ — Mozilla (developer documentation) · Complete article read7November2026, modified12October2026: origin-bound strings, ordinary persistence, private session lifetime, policy exceptions; no guarantee of indefinite availability.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.