As an avid computer user and now programmer, it recently dawned on me, how desensitized I was to receiving cookie pop-ups, you know the one, asking you to allow or deny website's access to store cookies on your device.
I always hit 'allow' as fast as I can just to get the pop-up out of the way and continue browsing the site I was on.
But I had to ask myself, "Do I even know what I'm agreeing to?".
I didn't. I vaguely understood it was to make my user experience better, somehow. But after clicking that 'allow' button, what was to follow was unbeknownst to me.
What Exactly Are Cookies?
Invented by programmer Lou Montoulli, browser cookies (a.k.a internet/web/HTTP cookies) are text files that help track your user session, and identify who you are as a visitor, and what you may like to see render on your webpage. Browser cookies are browser independent, so the browser cookies that are stored on your device on e.g., Google will not be available in e.g., Firefox.
Yes, that sounds kinda creepy, but browser cookies can be very helpful.
How Are They Helpful?
Imagine if every time you online shopped and navigated to different parts of the website, everything you managed to save to your cart, gets removed. That would be frustrating for you, the customer, and that would be an expensive liability to the business.
That's where cookies come in.
With the numerous amount of websites the average person has to sift through in one day alone, imagine having to remember the username and password for every single site you engage with and then having to re-enter that information every time you go to that site after closing it out.
That's where cookies come in.
In the modern age of technology, escaping the viewing of ads is near impossible as that's how most free websites make their income, so rather than being bombarded with ads that would be considered undesirable by a user, the personalization of ads that align with what the user likes, helps make the experience more bearable to endure.
That's where cookies come in.
As you can see, browser cookies intend to streamline your web browsing experience, nothing too creepy going on here. The data that cookies store cannot be changed. Also, the amount of data cookies can hold, reach a merely 4kB. Compared to local Storage and sessionStorage, storing 5MB.
So, How Exactly Does It All Work?
I'm glad you asked! Remember those text files, that essentially makeup what a cookie is? Those files are given to a user's browser of choice by a web server. And since web servers aren't intended to hold memory, the cookie that is created from a user's activity and input from a site is compiled into a file called a 'session id' that can be accessed and stored through a user's browser.
Subsequently, when a user visit the same website the browser will send that file to the web server. The web server will check for the session id and in return send data back to the browser. In order to present user's with their choice of web page personalization and in some cases an already logged in account.
Types of Cookies
1. Session Cookies
Session cookies do not store data in your device, nor do they remain once your browser is closed.
2. Persistent Cookies
Unlike session browser cookies, persistent cookies are stored on your device until you delete them or they expire.
3. First-Party Cookies
Are browser cookies that are sourced from the original website a user visits.
4. Third-Party Cookies
These are the cookies that are stored in a user's device from advertisements, search engines, and social media sites frequented by the user.
That's How The Cookie Crumbles
So now the next time you accept a website's cookies, I hope after reading through this article, you'll feel more confident as a developer knowing what you're doing on the internet and learning how bits and pieces of the web works as a whole.
Top comments (0)