Vezi pagina în română

IT Glossary

Cookies (HTTP cookies): what they are and how they work

Small text files that websites leave in the browser: they keep the session open, the basket full and the language chosen — and some of them track the visitor.

6
sections
7
questions answered

A cookie is a small text file, a name–value pair, that a website saves in the visitor's browser and that the browser sends back with every following request, so the site can recognise the visitor. Thanks to it you stay logged in, the shopping basket survives navigation, the site remembers the language you chose and it can count visits. The mechanism exists because HTTP does not remember earlier requests: every page request is a fresh conversation, and the cookie is the memory the site adds. The format is standardised in RFC 6265 (IETF, April 2011).

For your company's website, the practical distinction is between strictly necessary cookies (session, basket, security) and analytics or marketing cookies. In the EU, Article 5(3) of the ePrivacy Directive (2002/58/EC) allows non-essential cookies only after the visitor's informed consent; see cookie consent for what a compliant banner looks like. Third-party cookies have not disappeared everywhere: Chrome keeps them enabled by default, Safari blocks them and Firefox isolates them per site. Cross-site measurement therefore stays incomplete, and first-party data (accounts, newsletter, purchase history) is the one source you can rely on.

Why it matters for your business

A functional experience for customers

Sessions that do not drop, baskets that wait and preferences that are remembered — the baseline comfort visitors simply assume is there.

Measurement of what actually works

With consent, analytics cookies show where customers come from and which pages persuade them — the fuel for every marketing decision you make.

Compliance without fines

A correct banner — accept and refuse equally simple, scripts blocked before agreement — meets the consent requirements; the details are on the cookie consent page.

The server sends a Set-Cookie header in its response, the browser stores the cookie, and with every request to the same domain it sends the cookie back in a Cookie header. Example: after login, the site stores a session identifier in the cookie, not your password, and uses it to recognise you on the next page.

A cookie holds a name, a value, a domain, a path, an expiry date (Expires or Max-Age) and, optionally, the Secure and HttpOnly attributes. The standard requires browsers to support at least 4,096 bytes per cookie, 50 cookies per domain and 3,000 in total (RFC 6265, section 6.1). A cookie is text, not a program: it cannot run on your device.

The first standard was RFC 2109, from February 1997, authored by D. Kristol (Bell Labs) and Lou Montulli (Netscape). The current version is RFC 6265 from 2011; its successor, rfc6265bis, is still an Internet-Draft, not an RFC.

Types of cookies

By lifetime, cookies are session or persistent. Session cookies have no expiry date and are kept until the session ends, as the browser defines it; a browser that restores tabs on restart may let a session cookie survive. Persistent cookies have an expiry date, and since August 2022 Chrome accepts no more than 400 days. Example: the _ga cookie from Google Analytics defaults to a 2-year expiry, so in Chrome it lasts at most 400 days per setting.

By who sets them, cookies are first-party (set by the domain you are visiting) or third-party (set by another domain: an ad network, an embedded video, a social button). Third-party cookies underpin cross-site tracking and remarketing.

By purpose, they split into strictly necessary, preference, statistics and marketing cookies — the split the law uses too; the rules are on the cookie consent page.

The security attributes are independent of each other. Secure means the browser sends the cookie only over HTTPS; it does not mean the value is encrypted. HttpOnly means JavaScript cannot read the cookie, which protects the session if the page ends up with an injected script.

Want an estimate for your project?

Message us on WhatsApp. We reply the same working day, and the first 30-minute call is free.

Book a free call

The cache keeps copies of files (images, CSS, JavaScript) so a page loads faster on the next visit; those copies are not sent to the server. A cookie is a small piece of data the site reads on every request to recognise you. They live in different places in the browser, and clearing them has different effects.

According to Google, after you clear cookies, if you were signed in you will have to sign in again. After you clear the cache, some sites may load more slowly, because images and other content have to load again. A third store, localStorage, also stays in the browser but is not sent to the server automatically with each request. For more on the cache and clearing it, see the dedicated page.

Third-party cookies in 2026

Safari has blocked third-party cookies by default since 24 March 2020 (Safari 13.1, iOS 13.4). Firefox has applied Total Cookie Protection by default since 14 June 2022, which confines each cookie to the site where it was set, so a third-party cookie can no longer follow the visitor from one site to another.

Chrome took a different road. On 22 April 2025 Google announced it would keep the user-choice approach in settings, with no new standalone prompt; Incognito mode already blocks third-party cookies by default. On 17 October 2025 Google also announced it would retire the Privacy Sandbox advertising APIs (Topics, Protected Audience, Attribution Reporting and others).

For a company, the practical result is cross-site measurement that is incomplete on Safari and Firefox. Customer accounts, the newsletter and your own purchase history remain the source that no browser decision can change.

Frequently asked questions

What does “cookies” mean?

Cookies is the plural of cookie, a small text file a website saves in your browser so it can recognise you on your next request. Either form means the same small piece of data.

What is the difference between cookies and cache?

The cache keeps copies of files (images, CSS, scripts) so pages load faster; a cookie keeps a small piece of data that lets the site recognise you. Clearing cookies signs you out of sites, while clearing the cache only makes the first load slower.

Are cookies dangerous?

No, a cookie is text and cannot run code on your device. The real risks are different: cross-site tracking through third-party cookies and theft of the session cookie. The Secure and HttpOnly attributes, set by the site, reduce the second risk.

What happens if I delete my cookies?

You are signed out of the sites where you were logged in, saved preferences reset, and a shopping basket without an account may empty. In Chrome: More → Delete browsing data → “Cookies and other site data”.

How long does a cookie stay in the browser?

A session cookie disappears when the browser session ends, and a persistent one at the expiry date the site set. Chrome accepts no more than 400 days, though. The Google Analytics _ga cookie defaults to 2 years, so in Chrome it lasts at most 400 days.

How do you see which cookies your website sets?

In Chrome press F12, open Application, then Storage → Cookies and pick the domain. You see each cookie's name, value, domain, expiry and attributes. Take this inventory before choosing a banner, so you start from what your site really sets.

Are third-party cookies going away?

Not in Chrome: Google decided on 22 April 2025 to keep the user-choice approach in settings. Safari has blocked them since 2020 and Firefox has isolated them per site since 2022. The safe strategy remains first-party data: accounts, newsletter, purchase history.