A Uniform Resource Locator (URL) tells a browser where a resource is located and how to retrieve it.
| Part | Example | Description |
|---|---|---|
| Scheme | https:// | Protocol to use – http or https. |
| Domain | www.example.com | Host name that is looked up via DNS to obtain an IP address. |
| Port (optional) | :443 | Network port; default 80 for HTTP, 443 for HTTPS. |
| Path | /products/item.html | Location of the file on the server. |
| Query (optional) | ?id=42&ref=home | Parameters passed to the server. |
| Fragment (optional) | #reviews | Client‑side reference to a part of the page. |
HTTP (or HTTPS) request to the web server. If a cookie has previously been set for this domain/path, the request includes a Cookie header.Set‑Cookie header) and the requested resource (HTML, CSS, JavaScript, images, …).
User enters URL
↓ DNS lookup → IP address
↓ TCP (or TLS) connection
↓ HTTP/HTTPS request
(Cookie header sent if a matching cookie exists)
↓ Server processes request
↓ Server response
(Set‑Cookie header may be included)
↓ Browser stores/updates cookie
↓ Browser renders the page
A cookie is a small (max ≈ 4 KB) piece of text that a web server asks a browser to store on the user’s device. On later requests to the same domain (and matching path), the browser automatically includes the cookie in the Cookie header, allowing the server to recognise the user and remember information about previous interactions.
Max‑Age. Survives browser restarts and is used for “remember‑me”, language preferences, or long‑term tracking.| Attribute | Purpose | Typical value / effect |
|---|---|---|
| Name=Value | Identifier and the data stored. | user=JohnDoe |
| Expires / Max‑Age | Defines the cookie’s lifetime. | Specific GMT date (persistent) or omitted (session). |
| Domain | Domain for which the cookie is sent. | .example.com |
| Path | Limits the cookie to a particular directory on the domain. | /account |
| Secure | Cookie is sent only over HTTPS connections. | Present → forces encrypted transmission. |
| HttpOnly | Prevents client‑side scripts (JavaScript) from reading the cookie. | Present → mitigates XSS‑based theft. |
| SameSite | Controls whether the cookie is included with cross‑site requests. | Strict, Lax, None (requires Secure). |
HTTP response from server: Set-Cookie: sessionId=7f9c3e2a; Path=/; Secure; HttpOnly; SameSite=Strict
Browser stores the cookie. On every subsequent request to example.com it sends:
Cookie: sessionId=7f9c3e2a
The server looks up sessionId in its database and knows which user is logged in.
Set-Cookie: rememberMe=JohnDoe; Expires=Wed, 20 Dec 2026 12:00:00 GMT; Path=/; Secure; HttpOnly; SameSite=Lax
This cookie remains until the stated date, allowing the site to pre‑fill the login form or auto‑sign‑in on future visits.
HttpOnly flag may steal session identifiers.SameSite is set appropriately.Secure flag – ensures the cookie is only sent over HTTPS, protecting it from network eavesdropping.HttpOnly – prevents JavaScript from accessing the cookie, reducing XSS risk.SameSite value:
Strict – cookie sent only for same‑site navigation (strongest CSRF protection).Lax – safe for most navigation while still blocking many CSRF attacks.None – cookie sent with all requests; must be paired with Secure.The browser is responsible for:
Set‑Cookie header.Cookie header of every subsequent HTTP/HTTPS request.This behaviour is an integral part of the “locate, retrieve and display” cycle described earlier, because the server’s response can depend on the cookie values sent with the request.
Set‑Cookie and Cookie headers appear.
User → enters URL
↓ DNS lookup → IP address
↓ TCP / TLS handshake
↓ HTTP/HTTPS request
(Cookie header if a matching cookie exists)
↓ Server processes request
↓ HTTP/HTTPS response
(Set‑Cookie header may be present)
↓ Browser stores/updates cookie
↓ Browser renders HTML, CSS, JS
Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.