Cambridge IGCSE · Topic 5.1
IGCSE Computer Science 0478 / Topic 5 / IGCSE

Websites that remember.

Add a jacket to your basket, click to another page, and the jacket is still there. Come back next week and the site greets you by name. Both tricks rely on cookies: small files a website asks your browser to keep.

The key idea

A cookie is a small text file sent by a web server and stored by the browser on the user's computer. It holds data about the user's visit; the browser sends it back to the site on later requests, so the site can recognise the user. A session cookie is stored in temporary memory and is deleted when the browser is closed. A persistent cookie is saved on the hard drive and remains until its expiry date or until the user deletes it.

how long each type of cookie lasts time browser closed session deleted when the browser closes persistent saved on the hard drive until expiry
Fig. 1: a session cookie ends with the browser session; a persistent cookie lasts until it expires
Section 01

What a cookie is.

HTTP on its own does not remember anything between one request and the next. Cookies give a website a memory. In the lab, add items to a basket, move between pages, then close and reopen the browser.

Section 02

Session or persistent?

The difference is how long the cookie lasts, which decides what it can be used for.

Session cookiePersistent cookie
Stored inTemporary memory (RAM)The hard drive / secondary storage
DeletedWhen the browser is closedOn its expiry date, or when the user deletes it
Typical useHolding items in a shopping basket while browsing one visitRemembering login details, preferences and personal details between visits
Examiner trap

A session cookie is not deleted when the user leaves the page or the website. It is deleted when the browser is closed.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is a cookie?

Quick check+10 XP

In the lab, what happens to the session cookie when the browser is closed?

Quick check+10 XP

Which use needs a persistent cookie?

Quick check+10 XP

When does a persistent cookie stop being stored?

Section 03

What cookies are used for.

The syllabus names four uses. For each, be ready to say which type of cookie would be used.

Worked example Pick the type
A user logs in to a bank website. The site must log the user out as soon as they close the browser. Which type of cookie should store the login?
  1. The login must not survive after the browser is closed.
  2. A persistent cookie would keep the user logged in until it expired, which is a security risk on a shared computer.
  3. A session cookie is deleted when the browser is closed.
Answer: A session cookie
Your turn
A news site shows every visitor's chosen language each time they return. Which type of cookie is used, and why?
Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

Which statement about session cookies is correct?

Exam style+20 XP

Which is a use of cookies named in the syllabus?

Exam style+20 XP

Where is a persistent cookie stored?

Exam style+20 XP

A website shows adverts for trainers after a user looked at trainers last week. What made this possible?

Skill unlocked

Cookies, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
What cookies are, session versus persistent cookies, and how cookies save personal details, track preferences, hold baskets and store logins.