Understanding Cookies: How Websites and Web Browsers Handle Your Data Behind the Scenes

Segun AjibolaSegun Ajibola
9 min read

Introduction

Hey there, want some cookies?

I know you already know what cookies are. A cookie is a baked or cooked snack or dessert that is small, flat and sweet....

Nah, not that. Not in a website. You will be learning about different cookies, this might not be yummy but you should know about it.

Have you ever been to a website and you're asked to 'Allow Cookies'? You just tap the "Allow" or "Accept" button without really understanding what they mean or going on behind the scene. That can put your privacy in great risk.

In this blog, you will learn:

  • What cookies are

  • What web browsers do with cookies

  • What websites do with cookies

  • Cookies and law

  • How to clear cookies

  • If you're better off without cookies?

Meaning of Cookies

When a new website loads in your browser, the connection between the web server and the browser is shut down. The server forgets everything about you.

How can the web browser remember information about you?

Cookies.

Cookies are data stored in small text files in your computer web browser. The files contain data that are used for various purposes. Cookies are created by web servers and sent to your device.

When you visit a website and you are asked to accept cookies, you give the website the permission to get data relating you to the website and store it in the web browser.

For example, a cookie can contain a user's name. This can be stored when he/she visits a web page for the first time and accept cookies, then the next time the user visits the page, the website remembers the name with the help of the cookie.

Picture of a request to accept cookies from an ipad.

Image credits -allaboutcookies.org

Uses of Cookies for the Browser

The popup to accept cookies in a websites can be so annoying, but because it's just a click, we quickly click "Yes" and move on.

You should know what web browsers do with cookies. Here are some.

  1. Authentication and Session Management: Cookies help browsers manage your sessions on websites. When you login and navigate to other pages in a website, you don't need to login again because the browser stores your session IDs or tokens. You don't need to re-authenticate with each request to a new page in the same or different tab.

  2. Remembering Preferences: When you make changes to a website from your browser, the browser remembers the changes the next time you access the website. Browsers can store preferences like languages, layout preferences, theme mode for that particular website and use it the next time you visit the website. This can make your web experience better.

  3. Tracking State: Cookies help browsers to track states and save your interaction with the website. For example, browsers can remember data about the items you put in a shopping cart of a ecommerce website, browsers can also use cookies to remember the previous details you filled in a form if you didn't finish filling the form the last time.

Uses of Cookies for a Website

Here's what a particular website can do when you accept cookies.

  1. Personalization: Websites use cookies to personalize the content you see based on previous interactions with the website. This includes recommendations, targeted advertising, and customized layouts.

  2. Web Analytics: Cookies are used to track your behavior in a website, the website owner can use cookies to know each page views, click-through rates, and session durations from your device. Website owners use this analytics to know where you spend more time in their website and identify what you love about their website.

  3. Advertising and Marketing: When websites owners use cookies to know what you love about their website, they know the kind of adverts to show you based on your interests. They also read your browser history to help them in their marketing campaigns targeted at you.

  4. Security: Cookies are also used for security purposes, such as protecting you against cross-site request forgery (CSRF) attacks or creating rate limits and user session management to prevent unauthorized access to sensitive areas of a website.

Overall, cookies helps you with lot of functionalities that enhance your web experience like personalizing content and remembering user preferences while providing data for website owners to optimize their marketing strategies.

There are different type of cookies and knowing the type the website you visit use will be crucial for you to understand what's going on behind the scenes.

Types of Cookies

  1. Session cookies: These are temporary cookies that are erased when you close your browser. They are used to track your activities in a tab. Example is remembering the items you added to a shopping cart.

  2. Persistent cookies: These cookies remain on your device after you close the browser. They are used to remember your preferences and settings for future visits to the website.

  3. First-party cookies: These are set and used by the website only. Example are storing your login data or website preferences.

  4. Third-party cookies: Have you searched for fancy bikes on YouTube and check Google only to get ads about bikes? Third-party cookies in action. They are set by external domains for tracking what you do in another website. They are mainly for advertising purposes in social media platforms.

Websites publicize information about how they use the cookies they collect and how you can customize it. Reading about it will help you understand how the website use cookies that contain data about you and what you do online.

Although you give website owners data about you, they are limited in what they can do with the information else they break a privacy law. Privacy and data tracking have led to increased rules and regulations regarding how cookies are used and managed by websites.

Cookies has its benefit for you as a website user but you should know what's going on behind the scene to draw the line between web experience and privacy violation against you.

You should know about the laws governing website owners with the cookies they collect.

Cookies and Law

Laws regarding cookies are different depending on where you live. But the popular regulation guiding cookie usage globally is the General Data Protection Regulation (GDPR), which applies to the European Union (EU) and the European Economic Area (EEA).

Here are some GDPR related to cookies:

  1. Consent: Website owners ask you clearly before storing or accessing cookies on your device, unless the cookies are strictly necessary for the functioning of the website. They must ask questions about cookies that you accept by clicking an "Accept" button or adjusting cookie settings.

  2. Transparency: Website owners must clearly state the type of cookies used, their purposes, and how users can manage or disable them. This information is mostly included in a cookie policy or privacy policy.

  3. Right to Withdraw Consent: Website users have the right to withdraw their consent to the use of cookies at any time. Websites owners must provide a way for users to say they don't allow cookies anymore even after accepting before.

  4. Data Protection: Tracking cookies that are used for advertising purposes must be collected and processed following the data minimization, purpose limitation, and data subject rights laws from GDPR.

  5. Data Transfers: If cookies that contains personal data are sent outside the EU or EEA, website owners must ensure that they inform users and protect the data.

In addition to the GDPR, many countries have their own laws and there are other law bodies regulating cookies and online privacy.

Here are some:

  1. California Consumer Privacy Act (CCPA)

  2. Personal Information Protection and Electronic Documents Act (PIPEDA)

  3. Brazilian General Data Protection Law (LGPD)

  4. Personal Data Protection Act (PDPA)

  5. Privacy Act

  6. Data Protection Directive (Directive 95/46/EC)

  7. ePrivacy Directive (often referred to as the "Cookie Law")

It's essential for website owners to know these laws and regulations in their region and ensure they comply with cookie-related requirements to protect user privacy and avoid legal consequences.

How to Clear Cookies in Your Browser

If you use Chrome browser on Windows, I'll show you how to automatically clear cookies that have been stored in your browsers.

I'm currently using Chrome version 120.0.6099.227 (Official Build).

Step 1: Click the 3 dots at the top right corner.

Step 2: Click the "Clear browsing data" option.

Step 4: Check the popup, note the Cookies and other site data.

Step 5: Read carefully, uncheck option you still want like cached images and files.

Step 6: Click the "Clear data" button.

Congratulations, you have cleared cookies, but are there anything you might be missing out?

Are you better off without cookies?

Bottom Line: Are you better off without Cookies?

Cookies can contain information like login credentials, user preferences, shopping cart contents, webpage analytics and browsing history.

It looks like it's doing you a favor - yes it is, but a closer look and you see the potential danger. You are accepting to give information that will be valuable for website owners in ways you are unaware of that could even be putting you at risks.

On the other end, if you don't accept cookies, web browsers may be limited in how they enhance your user experience.

The next time you are about to give websites permission to store cookies, you might wait to think twice and consider the credibility of the website.

Remember, you are choosing between convenience and privacy concerns.

Conclusion

Cookies are data created by the web servers and sent to the web browsers to get data about you and what you do on a website.

Browsers can use cookies to enhance your user experience by tracking state, remembering your saved data, getting you logged in across tabs and lot more.

Websites ask for your permission to use cookies to make targeted advertisements and track web pages analytics. They are controlled by several cookies related laws bodies like GDPR. They can also be sanctioned if they breach any privacy rules.

Understanding how cookies are used behind the scenes and their implications for online privacy is vital while using the web. Stay informed and take control of your online privacy.

That will be all. Hope you found value here as you learn more about the web.

If you enjoyed this article and want to see more content related to JavaScript and Web development, then follow me here, Twitter (X) or connect on LinkedIn. I'd be happy to count you as one of my ever-growing group of awesome friends on the internet.

You can also join my WhatsApp developer community and OpenSource community of 330+ developers learning and building cool projects.

If you also want to support me, you can also buy me a cup of coffee.

Thanks && Bye. ๐Ÿ‘‹

0
Subscribe to my newsletter

Read articles from Segun Ajibola directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Segun Ajibola
Segun Ajibola

I'm a front-end web developer, enjoys working with TailwindCSS and React. Love to contribute to Open Source and meet new people on Twitter.