The concept of cookies

karthik · updated · flag

No, not the eating type 🍪, but the tracking type 📄 that resides on your browser. We call this browser cookie! You probably have read countless explanations from the cookie consent dialogue boxes all over the internet, but here is a practical and simple explanation on what a cookie is.

You browse many sites every day. And on a few sites like Arclind Mindspace, you happen to log in. So when you log in, your browser puts up a face like this 🥺 and politely requests the website’s server with the credential you send and asks, “Hey, this is my username and password! Can you let me in? Pretty please?”

The server puts on a monocle like this 🧐 and checks your username and password against the records it has. Once it finds a match, it responds, “Hey, cool! Yeah, you do check out! You can access the requested page now. And here is a cookie file. Show this the next time for all requests so that I will remember you. Okay? Cool!”

So for all subsequent requests, all your browser needs to do is show this cookie file to the server for it to respond to you without the need for you to login again. And the cookie will always be tied to that domain. The browser wouldn’t let a domain B to access cookies from domain A or others. It’s okayish secure.

So to summarise, a cookie is a very small file sent by a server that you are logged in with. It’s intended design purpose is to keep track of your session state (whether you are logged in or not), personal preference like theme settings, form data, and non-critical things that can be saved on a user’s browser instead of the server.