Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A weather website stores a persistent cookie that remembers a user's home town. The cookie is saved on 3 March and lasts for days. The year is not a leap year, and March has days.
The browser sends the domain name to a domain name server (DNS). The DNS returns the IP address (asking another DNS if it does not know the name). The browser sends a request to the web server at that address, the server sends the page as HTML, and the browser renders it. A cookie is a small text file that a website stores on the device through the browser: a session cookie is deleted when the browser closes, a persistent cookie stays until its expiry date or until it is deleted.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The expiry date. From 3 March, days take us to 31 March. Two more days take us to 2 April, which is days after 3 March.
Step 2. Days left on 20 March. From 20 March to 2 April is days to 31 March and more: days.
Step 3. Closing the browser. A persistent cookie is saved in the device's storage, not only in memory. So it is still there the next day, and the website still knows the home town.
Step 4. A session cookie. No. A session cookie is deleted when the browser is closed, so on 11 March the website would not know the home town.
Answer: (a) 2 April. (b) days. (c) Yes, a persistent cookie stays after the browser closes. (d) No, a session cookie is deleted when the browser closes.
Check. days from 3 March to 2 April.
Log in to join the discussion.
Loading…