← IGCSE Computer Science Paper 1

Choosing session or persistent cookies for a scenario

Decide how long a cookie must last: session if it can go when the browser closes, persistent if it must last for later visits. Justify your choice with because.

Understanding Choosing session or persistent cookies for a scenario in IGCSE Computer Science Paper 1

What it does: A shared computer is a risk, so the cookie must disappear as soon as the browser closes. That makes it a session cookie. With no Expires or Max-Age, the cookie only lasts for the visit. This suits a cart that is only used during one visit.

Common mistakes: Line 1 is wrong. A bank login on a shared computer needs a session cookie, so the next user cannot get into the account after the browser closes. Line 1 should be cookie ← "session". The setting must last for many visits, so the cookie must be persistent. A session cookie would be deleted when the browser closes and the language would be forgotten. Line 4 should be cookie ← "persistent".

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 bank website lets you log in on a shared school computer. Which cookie type should it use?
Persistent cookie, because it keeps you logged in for next timeSession cookie, because it is deleted when the browser closes
Matches
Bank login on a library PC: use a persistent cookie because it is quicker next time.
↓
A persistent cookie stays on a shared computer after the browser closes, so the next person could use the account. A session cookie is the safe choice.
Applying
Meanings
Term
session or persistent
Meaning
Decide how long a cookie must last: session if it can go when the browser closes, persistent if it must last for later visits. Justify your choice with because.
Practice
Bank login on a shared PC: session cookie because it is deleted when the browser closes.
Testing
Gaps
COOKIE ← ""
Check Answer
Spots
1cookie ← "persistent"
2scenario ← "bank, shared PC"

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

The 'Gazelle' badge — Tuple Sprinter, 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 bank website lets you log in on a shared school computer. Which cookie type should it use?
A. Persistent cookie, because it keeps you logged in for next time
B. Session cookie, because it is deleted when the browser closes ✓
On a shared computer the next person could use a persistent login. A session cookie disappears when the browser closes, so the account stays safe.
2. A website remembers that you chose French as your language, and you want it to still be French in three months. Which cookie type fits?
A. Persistent cookie, because the setting must last for later visits ✓
B. Session cookie, because the setting must last for later visits
The setting must survive after the browser closes. Only a persistent cookie is stored on the device for a set time, such as months.
3. An online shop only needs to hold your basket during one visit. Which is the better choice?
A. Session cookie, because the basket is only needed until the visit ends ✓
B. Persistent cookie, because the basket is only needed until the visit ends
If the data is only needed for one visit, a session cookie is enough. It is removed when the browser closes, so nothing is stored for longer than needed.
4. Which answer is better for an exam question that asks you to choose a cookie and justify it?
A. Session cookie, because cookies are used on websites
B. Session cookie, because the data is only needed until the browser closes ✓
A justification must link the cookie type to how long the data must last. Saying that cookies are used on websites does not give a reason for the choice.
5. A user ticks 'Remember me' so they do not have to type their username again next week. Which cookie type is needed?
A. Persistent cookie ✓
B. Session cookie
The details must still be there next week, after the browser has been closed. A session cookie would be deleted, so a persistent cookie is needed.

Match the Pairs

Set-Cookie: lang=fr; Max-Age=15552000 → A persistent cookie: it lasts about 6 months, so the language setting is remembered on later visits.
Set-Cookie: cart=Item42 → A session cookie: it has no expiry time, so it is deleted when the browser is closed.
On a shared school computer, a bank login should use a session cookie because it is deleted when the browser closes and the next user cannot get in. → cookie_type = "session" # bank login, shared PC
A website that remembers your language choice for months needs a persistent cookie because the setting must still be there on your next visit. → cookie_type = "persistent" # language, months
Bank login on a library PC: use a persistent cookie because it is quicker next time. → A persistent cookie stays on a shared computer after the browser closes, so the next person could use the account. A session cookie is the safe choice.
One-visit shopping cart: use a persistent cookie for 5 years. → The cart is only needed during one visit, so it should be a session cookie. A persistent cookie that lasts 5 years is not needed and stores data for far too long.

Key Term

session or persistent
Decide how long a cookie must last: session if it can go when the browser closes, persistent if it must last for later visits. Justify your choice with because.

Fill in the Blanks

1. SCENARIO ← "bank login, shared computer" COOKIE ← "session"
Hint: Type the cookie type that is deleted when the browser closes, which is safest on a shared computer.
2. SCENARIO ← "language setting for months" COOKIE ← "persistent"
Hint: Type the cookie type that must last for later visits, even after the browser closes.
3. SCENARIO ← "one-visit shopping cart" COOKIE ← "session"
Hint: Type the cookie type that is enough when the data is only needed during one visit.
4. IF NeededLater THEN COOKIE ← "persistent" ELSE COOKIE ← "session"
Hint: Type the keyword that comes after the condition and starts the block that runs when it is true.
5. Session because the cart is not needed later
Hint: Type the linking word that joins your choice of cookie to your reason.

Spot the Error

Question 1
A cookie ← "persistent"
B scenario ← "bank, shared PC"
C why ← "because it is deleted"
D OUTPUT cookie, why
Line A — Line 1 is wrong. A bank login on a shared computer needs a session cookie, so the next user cannot get into the account after the browser closes. Line 1 should be cookie ← "session".
Question 2
A need ← "language for months"
B lasts ← "many visits"
C IF lasts = "many visits" THEN
D cookie ← "session"
E ENDIF
Line D — The setting must last for many visits, so the cookie must be persistent. A session cookie would be deleted when the browser closes and the language would be forgotten. Line 4 should be cookie ← "persistent".
Question 3
A scenario ← "language setting"
B cookie ← "session"
C why ← "because it is kept"
D OUTPUT cookie
Line B — A language setting must be remembered for months, so a persistent cookie is needed. A session cookie is deleted when the browser closes. Line 2 should be cookie ← "persistent".
Question 4
A scenario ← "language setting"
B lasts ← "for months"
C cookie ← "persistent"
D why ← "because it is deleted"
E OUTPUT cookie, why
Line D — The reason contradicts the choice. A persistent cookie is kept after the browser closes, it is not deleted. Line 4 should be why ← "because it is kept".
Question 5
A scenario ← "bank, shared PC"
B lasts ← "for many visits"
C cookie ← "session"
D OUTPUT cookie
Line B — A bank login on a shared computer should only last until the browser closes. Saying it lasts for many visits would suggest a persistent cookie. Line 2 should be lasts ← "until browser closes".

Student with a class code? Join your class →