# Web Browsers & Cookies

- **Track:** Cambridge IGCSE™ Computer Science (0478 / 0984) (CAMBRIDGE IGCSE 0478)
- **Module:** Section 5: The Internet & Security
- **Estimated Duration:** 15 minutes
- **Access:** Open Theory (All-Access for Interactive IDE &amp; Autotests)

---

## Theory & Conceptual Background

A browser retrieves web resources and presents them to the user. Its functions include interpreting HTML, applying CSS, running JavaScript, displaying pages, managing URLs/history/bookmarks and navigating between resources. A search engine is a service used to find resources; it is not the browser itself.

## Cookies preserve state

A cookie is a small item of data a site asks the browser to store. The browser sends relevant cookies with later requests to that site. HTTP requests alone do not remember a shopping basket; a cookie can carry an identifier that lets the server look up the basket.

## Worked example: a basket

A server gives the browser a basket identifier. The user adds a book. On the next request the browser sends the identifier, so the server retrieves that basket rather than treating the request as a new customer. The cookie need not contain the book list or the password.

**Session cookies** have no persistent expiry time: their lifetime depends on the browser session. Closing one tab does not normally delete them, and session restoration may preserve them across a restart. **Persistent cookies** have a specified lifetime and can remember a preference for later visits. This is a lifetime distinction, not a universal rule that one kind uses RAM and the other disk.

Cookies from another party can support tracking across sites that include that party's content. Preferences and sign-in convenience are benefits; unwanted tracking or a stolen session identifier are risks. Privacy settings and limiting third-party cookies can reduce tracking, sometimes at the cost of features. HTTPS protects cookies in transit but does not make a dishonest site trustworthy.

## Independent explanation

A shared computer remembers the previous user's language and sign-in state. Explain the benefit and the privacy risk, and justify signing out rather than merely closing a tab.

## Written practice and self-review

Web browsers allow websites to store HTTP cookies on a visitor's device.

1. State **two distinct legitimate benefits** of using cookies on an online retail shopping website.
2. Explain why privacy advocates raise concerns regarding the use of **third-party tracking cookies**, and describe how a user can protect their privacy.

Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.

---

## Interactive Exercises & Autotest Specifications

### Exercise 1: Concept Check: Apply the distinction (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Does closing one tab reliably delete a session cookie: yes or no? Cookie with a specified expiry lifetime: session or persistent? Can a cookie hold a basket identifier without the whole basket: yes or no?


**Starter Code:**
```text
{"prompt":"Concept Check: Apply the distinction","template":"1. Does closing one tab reliably delete a session cookie: yes or no? [blank_1]\n2. Cookie with a specified expiry lifetime: session or persistent? [blank_2]\n3. Can a cookie hold a basket identifier without the whole basket: yes or no? [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["yes","no","persistent","session","temporary"]}
```


### Exercise 2: Concept Check: Browser functions (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. The browser interprets HTML to display a page: yes or no? A locally saved copy used to avoid downloading a resource again is a what? A saved link to revisit a page is a what?


**Starter Code:**
```text
{"prompt":"Concept Check: Browser functions","template":"1. The browser interprets HTML to display a page: yes or no? [blank_1]\n2. A locally saved copy used to avoid downloading a resource again is a what? [blank_2]\n3. A saved link to revisit a page is a what? [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["yes","no","cache","bookmark","cookie","history"]}
```


### Exercise 3: Application: Shopping preferences (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Remembering a chosen language between visits usually needs a session or persistent cookie? Must every cookie contain the full shopping basket: yes or no?


**Starter Code:**
```text
{"prompt":"Application: Shopping preferences","template":"1. Remembering a chosen language between visits usually needs a session or persistent cookie? [blank_1]\n2. Must every cookie contain the full shopping basket: yes or no? [blank_2]","blanks":[{"id":"blank_1"},{"id":"blank_2"}],"word_bank":["persistent","session","yes","no"]}
```


