CookiesOptional for Computer Science
🎬 This chapter has a 12:38 video: Web Services →A website has no memory. Every request that arrives looks like the first one it has ever seen — and yet a shopping site remembers what is in your basket, and a school portal keeps you logged in. The trick is that the site does not remember you. Your browser does, and reminds it.
1What a cookie is
Two things in that definition are exam answers on their own. A cookie is stored on your computer, not on the website’s server. And it is a text file — plain words and values, which cannot run and is not a program.
The browser window is what you see. The box below it is the small file the website asked your browser to keep.
Nothing yet — the site has not been visited.
A cookie is stored by the browser, on your computer — one small text file per website.
2What cookies are used for
| Used for | What it means for you |
|---|---|
| Staying logged in | You type your password once, not on every page |
| Remembering a shopping basket | Items are still there when you come back |
| Preferences | Language, dark mode, font size stay as you set them |
| Counting visitors | The site can tell a returning visitor from a new one |
| Advertising | Building a record of the sites you visit, to target ads |
The cloakroom token
3Kinds of cookie
4The privacy question
A cookie cannot read your files, cannot carry a virus and cannot run a program — it is text. What it can do is build a record of where you have been, which is a privacy problem rather than a security one.
5From the board papers
▶Show the answer
A cookie is a small text file that a website stores on the visitor’s computer through the browser, and which the browser sends back on every later visit to that site.
Two points of significance:
- It lets the website recognise a returning visitor, so a user can stay logged in and a shopping basket is not lost.
- It stores the user’s preferences — language, theme, settings — so the site opens the way the user left it.
▶Show the answer
Browser cookies are small text files that a website asks the browser to save on the user’s computer, holding a little data such as a user name, a session number or a preference. The browser sends them back to the same website on later visits.
Advantage: browsing becomes faster and easier — the user does not have to log in or set their preferences again on every visit.
Reason (R): To make browsing the Internet faster and easier, it is required to store certain information on the server’s computer.CBSE sample paper 2022–23
▶Show the answer
A is true, R is false. The assertion is the correct definition of a cookie. The reason is wrong in one word: the information is stored on the user’s computer by the browser, not on the server’s computer. That one word is the whole question.
Where cookies are allowed, blocked or cleared is in the browser’s own settings — see Browser Settings.
6Check yourself
Where is a cookie stored?
Riya's shopping basket empties every time she closes the browser, but she stays logged in for weeks. Which two cookies are at work?
Which statement about cookies is TRUE?