You pick English on MyShop, close your phone, and open MyShop again the next day. The page is still in English. Yet MyShop's server serves thousands of people and remembers none of them.
A forgetful server
Every request is separate from the others. The server answers, then forgets. To the server, the next request comes from a stranger, even if it comes from the same phone a minute later.
A cookie: the ticket the browser carries
So that it still knows your choice, the server puts a small note in its reply, such as lang=en, which means the English language. This note is called a cookie. The browser keeps the cookie, then brings it back with every request to the same site. A cookie works like a ticket: the server writes it, the browser carries it, and the server only has to read it again.
Cookies hold a chosen language, a shopping cart, and the sign that you are logged in.
💡 A ticket only for whoever gave it
The browser brings a cookie from MyShop only to MyShop. Other sites never receive it.
TL;DR: A server remembers nobody. To still know your choices, it uses a cookie: a small note from the server that the browser keeps and brings back every time you come to the same site.
⚡ A forgetful server
Meaning: Every request to a server is separate from the others. The server answers, then forgets. To the server, the next request comes from a stranger, even if it comes from the same phone a minute later.
⚡ A cookie: the ticket the browser carries
Guess first: you pick English on MyShop, and MyShop's server puts a small note, lang=en, in your browser. This note is called a cookie. The next day you open MyShop again on the same phone. Which language is the page in?
English, right away. The browser brings lang=en back, and the server only has to read it.
Meaning: A cookie is a small note from the server that the browser keeps, then brings back with every request to the same site. It works like a ticket: the server writes it, the browser carries it.
⚡ A ticket only for whoever gave it
Meaning: The browser brings a cookie from MyShop only to MyShop. Other sites never receive it. Cookies hold a chosen language, a shopping cart, and the sign that you are logged in.