← IGCSE Computer Science Paper 1

Cookie use: storing login details

A small file a website saves in your browser to remember you are logged in, so you do not have to type your username and password on every page.

Understanding Cookie use: storing login details in IGCSE Computer Science Paper 1

What it does: The login status is stored in a cookie, so the user is not asked to enter a username and password on every page. The 'Remember me' option keeps a cookie stored for longer, so you can still be logged in when you return another day. If you stay logged in, the next person could use the cookie to open your account. Logging out ends the login.

Common mistakes: After a successful login the login cookie must record that the user IS logged in, so it should be set to TRUE. FALSE would make the site ask for the password again. The account page should only be shown when the cookie says the user is logged in. The test must be loggedIn = TRUE.

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 website saves a login cookie after you sign in. What does this let you do?
Skip the login step on any website in the worldMove between pages without typing your username and password again
Matches
Tick 'Remember me' on a school library computer
↓
On a shared computer, a remember me cookie stays saved in the browser, so the next person could open your account.
Applying
Meanings
Term
login cookie
Meaning
A small file a website saves in your browser to remember you are logged in, so you do not have to type your username and password on every page.
Practice
IF login_cookie EXISTS THEN
Testing
Gaps
IF loginCookieExists
Check Answer
Spots
2IF checkLogin() = TRUE THEN
3 SAVE cookie loggedIn = FALSE

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

The 'Jellyfish' badge — Flow Controller, 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 website saves a login cookie after you sign in. What does this let you do?
A. Skip the login step on any website in the world
B. Move between pages without typing your username and password again ✓
A login cookie is stored by one website. It remembers you are logged in on that site, so you do not have to sign in on every page.
2. Which statement about a login cookie is correct?
A. It speeds up your internet connection
B. It stores your login status so the site knows you are signed in ✓
The cookie holds login details or a login status. It does not change the speed of your connection.
3. You stay logged in while you browse a shop's pages during one visit. What is most likely being used?
A. A cookie holding your login status ✓
B. A new username and password typed on each page
The cookie lets the site recognise you from page to page, so you do not need to re-enter your details each time.
4. You tick 'Remember me' when you log in. What does the website do?
A. Saves a cookie so you can be recognised on a later visit ✓
B. Deletes the cookie as soon as you close the browser
The 'Remember me' option keeps a cookie stored for longer, so you can still be logged in when you return another day.
5. You are using a shared school computer. What is the safest choice after you finish using your account?
A. Log out so the login cookie no longer keeps you signed in ✓
B. Just close the tab and leave the account logged in
If you stay logged in, the next person could use the cookie to open your account. Logging out ends the login.

Match the Pairs

Set-Cookie: loggedIn=true → The server tells the browser to store a login status cookie so the user stays logged in on later pages.
Set-Cookie: remember=yes; Max-Age=2592000 → A remember me cookie that lasts 30 days, so the user stays logged in on future visits.
A cookie stores a login status so the user stays logged in while moving between pages during a visit → loggedIn=true
Logging out on a shared computer deletes the login cookie so the next person cannot use your account → loggedIn=; Max-Age=0
Tick 'Remember me' on a school library computer → On a shared computer, a remember me cookie stays saved in the browser, so the next person could open your account.
Close the browser without clicking Log out on a shared PC → The login cookie may still be stored, so the next user could still be logged in as you.

Key Term

login cookie
A small file a website saves in your browser to remember you are logged in, so you do not have to type your username and password on every page.

Fill in the Blanks

1. IF loginCookieExists THEN DISPLAY "Welcome back" ENDIF
Hint: Type the keyword that starts the actions to run when the condition is true.
2. IF rememberMe = TRUE THEN cookieType ← "persistent" ENDIF
Hint: Type the cookie type that stays on the computer after the browser is closed.
3. IF userClicksLogout THEN DELETE loginCookie ENDIF
Hint: Type the command that removes the login cookie when someone logs out on a shared computer.
4. IF loginCookieFound = FALSE THEN DISPLAY loginForm ENDIF
Hint: Type the Boolean value that means no login cookie was found, so the user must type their details.
5. IF sharedComputer = TRUE THEN cookieType ← "session" ENDIF
Hint: Type the cookie type that is deleted when the browser closes, which keeps a shared computer safer.

Spot the Error

Question 1
A INPUT username, password
B IF checkLogin() = TRUE THEN
C SAVE cookie loggedIn = FALSE
D ENDIF
Line C — After a successful login the login cookie must record that the user IS logged in, so it should be set to TRUE. FALSE would make the site ask for the password again.
Question 2
A ON PAGE LOAD
B READ cookie loggedIn
C IF loggedIn = FALSE THEN
D SHOW account page
E ELSE SHOW login form
F ENDIF
Line C — The account page should only be shown when the cookie says the user is logged in. The test must be loggedIn = TRUE.
Question 3
A INPUT rememberMe
B IF rememberMe = TRUE THEN
C SET cookie type session
D ENDIF
Line C — A Remember me option needs a persistent cookie, which is stored after the browser closes. A session cookie would be deleted and the user would have to log in again.
Question 4
A IF user clicks LOGOUT THEN
B KEEP cookie loggedIn
C SHOW login form
D ENDIF
Line B — On logout the login cookie must be deleted. If it is kept, the next person on a shared computer could open the account without a password.
Question 5
A INPUT rememberMe
B IF rememberMe = FALSE THEN
C SAVE cookie loggedIn = TRUE
D SET cookie type persistent
E ENDIF
Line D — If the user does not choose Remember me (for example on a shared computer), a session cookie should be used so it is deleted when the browser closes. It should not be persistent.

Student with a class code? Join your class →