Topic 5 · The internet and its uses
Cookies: session and persistent
▶ Watch the video lessonShort, exam-focused explanation of this topic on the CS with Aamir YouTube channel.A cookie is a small text file that a web server sends to your web browser, which stores it on your device. The next time you visit the website, the browser sends the cookie back, so the website can recognise you and remember information about you.
The two types of cookie
| Session cookie | Persistent cookie | |
|---|---|---|
| Where stored | Temporarily, in the browser's memory (RAM) | On the device's storage (e.g. hard disk or SSD) |
| How long it lasts | Deleted when the browser is closed | Kept until its expiry date or until the user deletes it |
| Typical use | Keeping items in an online shopping basket during one visit | Remembering login details and preferences between visits |
What are cookies used for?
- Saving personal details, so you don't have to type them in every time.
- Storing login details, so you stay logged in.
- Holding items in an online shopping basket.
- Remembering preferences, such as language or dark mode.
- Tracking which pages a user visits, so that targeted adverts can be shown.
- Counting and analysing visitors to a website.
Advantages and disadvantages
Benefits for the user: faster, more personalised browsing; no need to log in or re-enter details every time; shopping baskets are not lost while you browse.
Concerns: persistent cookies can be used to track a user's browsing, which some people see as an invasion of privacy. Users can delete cookies or block them in their browser settings, although some websites will not work properly without them.
Exam tips
- A cookie is a text file – it is not a program and cannot run, so it is not a virus.
- For "describe the difference", always compare where each type is stored and when it is deleted.
- Give a specific example of use for each type.
You can see a real example on this website: our Privacy Policy explains the cookies used here.
Want the full topic notes, slides and worksheets? See Notes & Slides, practise with the free CS with Aamir Quiz App, or order the O Level Computer Science Study Guide.