Browser function: storing cookies

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Browser function: storing cookies

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Where is a cookie stored after a website sends it?
A Permanently on the web server only
B On the user's device, by the browser
2. What does the browser do with a stored cookie when you visit the same website again?
A Sends it to every website on the internet
B Sends it back to that website
3. Which part of the process sets a cookie?
A The website sends it to the browser, which stores it
B The browser invents it and keeps it secret from the website
4. A student does not want a site to remember them. Which browser setting helps?
A Block cookies in the browser settings
B Turn on the browser's bookmarks
5. How can a user remove the cookies already saved on their device?
A Delete them using the browser settings
B Wait for the web server to delete them

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Set-Cookie: theme=dark ASettings > Privacy > Delete cookies
2Cookie: theme=dark BThe browser stores the cookie on the user's device, not the website's server.
3A browser setting can stop websites from saving cookies on the device CThe website sends a cookie to the browser, which stores it on the user's device
4A browser setting can remove cookies that are already stored on the device DThe browser sends the stored cookie back to the website on a later visit
5The website keeps the cookie on its own server and the browser never stores it. EThe browser returns the cookie to the website on later visits, which is how the site recognises the user.
6The browser keeps every cookie and never sends it back to the website. FSettings > Privacy > Block cookies

Definitions

cookie

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
HTTP/1.1 200 OK __________: theme=dark
2.
GET /index.html HTTP/1.1 Host: www.shop.com ______: theme=dark
3.
document.______ = "theme=dark";
4.
__ cookieStored = TRUE THEN SEND cookie TO website ENDIF
5.
IF blockCookies = TRUE ____ DELETE cookie ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A BROWSER visits shop.com
B SERVER sends Cookie: id=7
C BROWSER stores cookie on device
Question 2
A Browser requests shop.com
B Server sends cookie id=7
C Browser stores cookie
D Browser sends it to ads.com
Question 3
A Browser setting: Block cookies
B Site sends Set-Cookie: id=3
C Browser stores cookie
Question 4
A First visit to shop.com
B Browser has no cookie for it
C Browser sends Cookie: id=5
D Server sends Set-Cookie: id=5
Question 5
A visit 1: server sends cookie
B browser saves cookie on device
C visit 2: server sends it back

Answer Key

Browser function: storing cookies
Section A: Quick Questions
Q1
B — On the user's device, by the browser
Q2
B — Sends it back to that website
Q3
A — The website sends it to the browser, which stores it
Q4
A — Block cookies in the browser settings
Q5
A — Delete them using the browser settings
Section B: Match the Pairs
Q1
Set-Cookie: theme=dark → The website sends a cookie to the browser, which stores it on the user's device
Q2
Cookie: theme=dark → The browser sends the stored cookie back to the website on a later visit
Q3
A browser setting can stop websites from saving cookies on the device → Settings > Privacy > Block cookies
Q4
A browser setting can remove cookies that are already stored on the device → Settings > Privacy > Delete cookies
Q5
The website keeps the cookie on its own server and the browser never stores it. → The browser stores the cookie on the user's device, not the website's server.
Q6
The browser keeps every cookie and never sends it back to the website. → The browser returns the cookie to the website on later visits, which is how the site recognises the user.
Section C: Definitions
Q1
cookie — A small file a website sends to your browser. The browser stores it on your device and sends it back to that website on later visits. Browser settings can block or delete it.
Section D: Fill in the Blanks
Q1
HTTP/1.1 200 OK Set-Cookie: theme=dark
Q2
GET /index.html HTTP/1.1 Host: www.shop.com Cookie: theme=dark
Q3
document.cookie = "theme=dark";
Q4
IF cookieStored = TRUE THEN SEND cookie TO website ENDIF
Q5
IF blockCookies = TRUE THEN DELETE cookie ENDIF
Section E: Spot the Error
Q1
B — A server gives a cookie to the browser with a Set-Cookie header. Cookie is the header the browser uses to send it back. Line 2 should be 'SERVER sends Set-Cookie: id=7'.
Q2
D — The browser returns a cookie only to the website that sent it. Line 4 should send it back to shop.com, not to another site.
Q3
A — The browser only stores the cookie because cookies are allowed. If they were blocked, line 3 would not happen. Line 1 should say 'Allow cookies'.
Q4
C — On a first visit the browser has no stored cookie for the site, so it has nothing to send. The server sends the cookie afterwards. Line 3 should say that the browser sends no cookie.
Q5
C — On the later visit the browser is the one that returns the stored cookie to the website. The server does not send it back. Line 3 should say 'browser sends it back'.