What Are Cookies?

Despite their friendly name, cookies have a bit of a bad reputation. The constant pop-ups asking you to accept or reject them, along with the myths surrounding them, have led many people to believe they're some kind of virus or spying mechanism. In reality, they're a basic building block of how the modern Web works.


A cookie is a small text file that a website asks your browser to store. Its purpose is to remember information related to your visit so the site can recognize your browser when you come back.


A cookie isn't a program, it doesn't run code, doesn't install software, and can't access the files on your computer. It simply stores information as text, which your browser then sends back to that same website on future requests.


It might hold data like a session identifier, your chosen language, the contents of a shopping cart, or a page display preference.

Where Does the Term "Cookie" Come From?

Even though we associate the word cookie with the internet today, its origin goes back much further than the Web. The term comes from the computing expression magic cookie, used in Unix systems since the 1970s to describe a small piece of data that one program handed off to another. Whoever received that data didn't need to know what was inside it, they just had to hold onto it and hand it back later to identify themselves or continue an operation.

In turn, the name magic cookie was inspired by fortune cookies, those familiar treats that hide a small message inside. In a similar way, a magic cookie held a small piece of information whose meaning was only known to the program that had created it.

When engineer Lou Montulli developed web cookies for the Netscape browser in 1994, he reused that same concept: the server sends a small piece of data to the browser, and the browser holds onto it to send back on future visits. Since the idea was practically the same as Unix's magic cookies, the name cookie stuck for this technology and is still used today.

How Do They Work?

The process happens in a matter of milliseconds:


  • You visit a website;
  • The server responds by sending the page and, if needed, one or more cookies;
  • Your browser stores those cookies;
  • Every time you visit that same site again, your browser sends them back along with the request.

Thanks to that exchange, the server can recognize that it's the same browser that visited the page before.

What Are They For?

Cookies make for a much more comfortable, personalized experience.


Some of their most common uses are:


  • Keeping you logged in after signing in.
  • Remembering the contents of a shopping cart.
  • Saving your preferred language or region.
  • Storing site settings.
  • Measuring browsing statistics.
  • Showing personalized content or advertising.

Without them, many sites would work in a much more limited way. Every page change could require logging back in or resetting your preferences.

Types of Cookies

While there are different ways to classify them, four categories tend to matter most:

Session Cookies

These only exist while the browser stays open. Once you close every browser window, they're automatically deleted. Their main job is to keep a user's session active during the visit, letting the site recognize the user as they move between different pages or tabs in the same browser.

Persistent Cookies

These stay stored on the device even after the browser is closed. How long they last depends on what they were created for and how the website is configured. It's common to see cookies set to last 15 days, 30 days, 60 days, 90 days, 6 months or 1 year, though some may expire sooner or stick around for several years.

Generally, shorter time frames are used for temporary functions, like keeping a session active or remembering a shopping cart for a few weeks. Longer time frames, on the other hand, tend to be used to hold on to user preferences, recognize returning visitors, run statistical analysis, or remember settings across visits.

First-Party Cookies

So far we've classified cookies by how long they last. From this point on, we'll classify them by who creates and manages them. First-party cookies are created and managed by the same website the user is visiting. As we saw earlier, they can be either session or persistent cookies. They're mainly used for essential functions, like keeping a session active, remembering user preferences (language, theme or region), holding on to shopping cart contents, and making sure the website works correctly.

Third-Party Cookies

If first-party cookies are created by the website you're visiting, third-party cookies are generated by outside services embedded in that page.

These cookies are created by companies or platforms unrelated to the website itself, like analytics tools, ad services, video players, social media buttons or tracking systems. They're used to gather information about browsing activity, measure campaign performance, personalize ads, or integrate features from other services.

Because they can track a user's activity across different websites, third-party cookies have become the subject of intense privacy debate. For this reason, major browsers and many companies are progressively limiting or phasing them out in favor of more privacy-friendly technologies.

Why Do All Sites Show a Cookie Notice?

Now that we know the main types of cookies, a very common question comes up: why does practically every website show a cookie notice when you visit?

For many years, cookies operated almost invisibly to users, and most people had no idea that small files were being stored in their browser.

However, as personalized advertising and cross-site user tracking grew, many countries introduced regulations to protect privacy.

Rules like the European Union's General Data Protection Regulation (GDPR) require that users be informed about the use of certain cookies and be able to choose which ones to accept and which to reject.

That's why it's now standard to see a cookie consent banner as soon as you land on a website.

What's Worth Checking Before Accepting Cookies?

Even though many people just click "Accept" automatically, it's worth reviewing what types of cookies a website is requesting and what they'll be used for:


  • Necessary cookies: enable a site's basic functionality, like keeping a session active or remembering shopping cart contents. These generally can't be turned off.
  • Preference cookies: remember settings like language, region or visual theme to improve the user experience.
  • Analytics cookies: gather information about how a site is used, helping its administrators understand how visitors navigate and improve the content.
  • Advertising cookies: allow personalized ads based on a user's interests and browsing habits.
  • Third-party cookies: worth checking which companies will receive the collected information, especially when ad platforms or social networks are involved.

Most modern sites let you accept all cookies, reject them, or configure which ones to allow individually. If privacy is a priority for you, taking a few seconds to review these options can help you keep more control over the information you share.

Common Myths About Cookies

Cookies tend to be surrounded by misconceptions:


  • "Cookies are viruses."
    No. They're text files. They can't run programs or infect a device.

  • "Cookies can read all my files."
    No. A cookie only stores the information the website chose to save. It can't access the files on your computer or read information from other websites.

  • "Cookies store my password."
    No. Modern web applications typically store a session identifier or token, not the user's password.

  • "If I delete cookies, my computer will run worse."
    No. Deleting cookies doesn't affect your computer's performance. What will happen is that many sites will stop remembering your preferences, active sessions or settings, so you'll likely need to log back in or reconfigure them.