← IGCSE Computer Science Paper 1

Session cookies

A cookie stored temporarily in memory while you browse. It has no expiry date, lasts only for one visit and is deleted when the browser is closed.

Understanding Session cookies in IGCSE Computer Science Paper 1

What it does: The cookie has no Expires or Max-Age part, so the browser treats it as a session cookie and deletes it at the end of the visit. An expiry date makes the cookie persistent, so it stays on the device. A session cookie has no expiry date.

Common mistakes: The cookie is a session cookie, which is temporary. A persistent cookie would be saved with an expiry date and would not be deleted when the browser closes. Line 2 should be 'Server sends a session cookie'. A session cookie has no expiry date. Adding Max-Age gives it a lifetime, which makes it a persistent cookie. Line 1 should be 'Set-Cookie: id=7'.

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 477–489) and word search (Modules 464–489).

Take this worksheet further — free with Cloodit

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

Learning
Duo
When is a session cookie deleted?
When the browser is closedAfter 30 days
Matches
A session cookie is saved on the hard drive for 30 days
↓
A session cookie is held temporarily in memory and is not saved for days. A cookie that is kept for 30 days is a persistent cookie.
Applying
Meanings
Term
session cookie
Meaning
A cookie stored temporarily in memory while you browse. It has no expiry date, lasts only for one visit and is deleted when the browser is closed.
Practice
HTTP/1.1 200 OK
Testing
Gaps
: sid=a1b2c3
Check Answer
Spots
1User visits a shop website
2Server sends persistent cookie

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

The 'Penguin' badge — List Waddler, 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. When is a session cookie deleted?
A. After 30 days
B. When the browser is closed ✓
A session cookie is temporary. It is deleted as soon as the browser is closed, so it lasts only for one visit.
2. Where is a session cookie held while you browse?
A. In memory ✓
B. Permanently on the web server
A session cookie is held temporarily in memory while the browser is open. It is not kept for later visits.
3. A session cookie has an expiry date set a year ahead.
A. False ✓
B. True
A session cookie has no expiry date. A cookie with a future expiry date is a persistent cookie.
4. How long does a session cookie last?
A. Across many visits over weeks
B. Only for one visit ✓
A session cookie lasts only for one visit to the website. Lasting across many visits is what a persistent cookie does.
5. You close your browser, then open it again. What has happened to the session cookie?
A. It has been deleted ✓
B. It is still stored
Closing the browser deletes the session cookie, so it will not be there when you reopen the browser.

Match the Pairs

Set-Cookie: basket=3 → A cookie with no expiry date, so it is a session cookie and is deleted when the browser closes
session cookie → A cookie held in memory that lasts only for one visit and is deleted when the browser is closed
A session cookie has no expiry date, so it is not kept after the visit ends → Set-Cookie: sessionId=A7F2
A cookie that is kept after the browser closes has an expiry date, so it is NOT a session cookie → Set-Cookie: sessionId=A7F2; Expires=Fri, 01 Jan 2027
A session cookie is saved on the hard drive for 30 days → A session cookie is held temporarily in memory and is not saved for days. A cookie that is kept for 30 days is a persistent cookie.
A session cookie stays after you close the browser so you are logged in tomorrow → A session cookie is deleted when the browser is closed. Staying logged in the next day needs a persistent cookie.

Key Term

session cookie
A cookie stored temporarily in memory while you browse. It has no expiry date, lasts only for one visit and is deleted when the browser is closed.

Fill in the Blanks

1. Set-Cookie: sid=a1b2c3
Hint: Type the name of the HTTP response header a web server uses to send a cookie to the browser.
2. IF browserClosed = TRUE THEN DELETE sessionCookie ENDIF
Hint: Type the command that removes the session cookie when the browser is closed.
3. IF cookie.expiry = NULL THEN cookieType ← "session" ENDIF
Hint: Type the value that shows no expiry date has been set for the cookie.
4. STORE sessionCookie IN MEMORY
Hint: Type the temporary storage where a session cookie is held while you browse, instead of the hard drive.
5. WHILE browserOpen = TRUE KEEP sessionCookie ENDWHILE
Hint: Type the Boolean value that means the browser is still open during the visit.

Spot the Error

Question 1
A User visits a shop website
B Server sends persistent cookie
C Cookie is held in memory
D User closes the browser
E Cookie is deleted
Line B — The cookie is a session cookie, which is temporary. A persistent cookie would be saved with an expiry date and would not be deleted when the browser closes. Line 2 should be 'Server sends a session cookie'.
Question 2
A Set-Cookie: id=7; Max-Age=999
B Browser holds it in memory
C Browser is closed
D Cookie is deleted
Line A — A session cookie has no expiry date. Adding Max-Age gives it a lifetime, which makes it a persistent cookie. Line 1 should be 'Set-Cookie: id=7'.
Question 3
A Session cookie created
B It has no expiry date
C It lasts for many visits
D Closing browser deletes it
Line C — A session cookie lasts only for one visit, because it is deleted when the browser is closed. It does not last for many visits. Line 3 should be 'It lasts for one visit'.
Question 4
A IF browser closed THEN
B SAVE session cookie
C ENDIF
Line B — Session cookies are deleted when the browser is closed, not saved. Line 2 should be 'DELETE session cookie'.
Question 5
A User opens a shopping site
B Server sends a session cookie
C Cookie is stored in memory
D Cookie expires in 30 days
E Browser is closed
F Cookie is deleted
Line D — A session cookie has no expiry date. A cookie that expires after 30 days would be persistent. Line 4 should be 'Cookie has no expiry date'.

Student with a class code? Join your class →