← IGCSE Computer Science Paper 1

Comparing session and persistent cookies

A session cookie is deleted when the browser closes; a persistent cookie is kept on the device until it expires. Cookies are text data, not programs.

Understanding Comparing session and persistent cookies in IGCSE Computer Science Paper 1

What it does: Session cookies last only for the current browsing session, so their lifetime ends when the browser is closed. Persistent cookies stay saved on the device after the browser closes, until the expiry date is reached. A common mistake is to call cookies programs or viruses. Cookies are only text data, so they cannot run or infect a computer.

Common mistakes: A session cookie is deleted when the browser closes. Line 3 should say DELETE, not KEEP. A persistent cookie needs an expiry date. Without Expires or Max-Age it would be a session cookie. Line 2 should include Expires=2027.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 490–499) and word search (Modules 490–509).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A session cookie is deleted when you close the browser.
TrueFalse
Matches
A cookie is a program that can run on my computer
↓
Cookies are not programs. They are small text files or pieces of text data, so they cannot run or do things by themselves.
Applying
Meanings
Term
session vs persistent cookie
Meaning
A session cookie is deleted when the browser closes; a persistent cookie is kept on the device until it expires. Cookies are text data, not programs.
Practice
Session cookie: deleted when browser closes
Testing
Gaps
DELETE cookie
Check Answer
Spots
2Set-Cookie: basket=3
3On browser close: KEEP

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Leopard' badge — Savannah Perfectionist, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A session cookie is deleted when you close the browser.
A. True ✓
B. False
A session cookie only lasts for one browsing session, so it is deleted as soon as the browser is closed.
2. Which cookie stays on your device until its expiry date?
A. Session cookie
B. Persistent cookie ✓
A persistent cookie is saved on the device until it expires or the user deletes it. A session cookie is deleted when the browser closes.
3. Where is a persistent cookie kept?
A. On the user's device until it expires ✓
B. In the browser's memory only, until the browser closes
A persistent cookie is stored on the device. A session cookie is usually held temporarily in memory and is lost when the browser closes.
4. Which statement about cookies is correct?
A. A cookie is a small piece of text data ✓
B. A cookie is a program that runs on your computer
A common mistake is to call cookies programs or viruses. Cookies are only text data, so they cannot run or infect a computer.
5. Which cookie would keep an online shopping cart only while you are on the site?
A. Persistent cookie
B. Session cookie ✓
A shopping cart only needs to last for the visit, so a session cookie is suitable because it is deleted when the browser closes.

Match the Pairs

Set-Cookie: cart=3; Expires=Fri, 01 Jan 2027 → A persistent cookie: it has an expiry date, so it stays on the device after the browser closes until that date.
Set-Cookie: sessionId=a81f → A session cookie: it has no expiry date, so it is deleted when the browser is closed.
A session cookie is kept in temporary memory and is deleted as soon as the browser closes → lifetime = until browser closes
A persistent cookie is stored on the device's storage and is kept until its expiry date → lifetime = until expiry date
A cookie is a program that can run on my computer → Cookies are not programs. They are small text files or pieces of text data, so they cannot run or do things by themselves.
A persistent cookie is deleted when the browser closes → This describes a session cookie. A persistent cookie is kept on the device until its expiry date, even after the browser closes.

Key Term

session vs persistent cookie
A session cookie is deleted when the browser closes; a persistent cookie is kept on the device until it expires. Cookies are text data, not programs.

Fill in the Blanks

1. IF browserClosed = TRUE THEN DELETE session cookie ENDIF
Hint: Type the cookie type that is deleted as soon as the browser closes.
2. IF today > expiryDate THEN DELETE persistent cookie ENDIF
Hint: Type the cookie type that stays on the device until its expiry date passes.
3. IF cookie.expiry = NULL THEN cookieType ← "session" ENDIF
Hint: Type the keyword meaning no expiry date has been set.
4. cookieIsProgram ← FALSE cookieIsVirus ← FALSE cookieIsText ← TRUE
Hint: Type the Boolean value that corrects the common mistake that cookies are programs.
5. IF cookieType = "persistent" THEN KEEP cookie UNTIL expiryDate ENDIF
Hint: Type the variable that says when a persistent cookie stops being kept.

Spot the Error

Question 1
A // Session cookie
B Set-Cookie: basket=3
C On browser close: KEEP
D Cookie type: text data
Line C — A session cookie is deleted when the browser closes. Line 3 should say DELETE, not KEEP.
Question 2
A // Persistent cookie
B Set-Cookie: a=1
C Closing browser: still stored
D Kept until expiry date
Line B — A persistent cookie needs an expiry date. Without Expires or Max-Age it would be a session cookie. Line 2 should include Expires=2027.
Question 3
A type <- 'persistent'
B expires <- '2027-01-01'
C stored <- 'temporary memory'
D OUTPUT type, stored
Line C — A persistent cookie is kept on the device's storage (such as the hard drive) until it expires. Temporary memory is where session cookies are held.
Question 4
A Cookies are small programs
B They cannot run or spread
C So they are not viruses
Line A — Cookies are small pieces of text data, not programs. They cannot run code, so they are not viruses. Line 1 should say text files.
Question 5
A Session cookie lifetime:
B until the expiry date
C Persistent cookie lifetime:
D until the expiry date
Line B — A session cookie lasts only until the browser closes. The expiry date is how long a persistent cookie lasts. Line 2 should be until the browser closes.

Student with a class code? Join your class →