What cookies are and how they work.
Cookies are small pieces of data that your browser stores for a website and sends back with later requests. They are used for things such as keeping you signed in, remembering preferences, analytics and advertising.
Small pieces of data that help websites remember.
A cookie is a small piece of text data that a website asks your browser to store. It holds a name and a value, is tied to a domain and can have an expiry date.
On their own, websites don’t remember a visitor from one page to the next, because each page is requested separately. Cookies fill that gap. They keep you signed in as you move between pages, remember what is in a shopping cart and store settings such as your language.
Some cookies are also used for analytics, to measure how visitors use a website, or for advertising, to understand visitors’ interests and show relevant ads. Not every cookie tracks visitors: many simply help the website work.
How a cookie is set and read.
- 01
A website sets a cookie
When you visit a page, the website’s server can include a Set-Cookie header in its response, or a script on the page can set the cookie.
- 02
Your browser stores it
The browser saves the cookie with details such as the domain it belongs to and when it expires. Browser settings can limit or block some cookies.
- 03
It is sent back on later requests
On later requests to that domain, the browser automatically sends the cookie back, so the site can recognise the session or remember the visitor’s settings.
- 04
It expires or is removed
Session cookies are usually deleted when the browser session ends. Persistent cookies are kept until their expiry date, unless the website or the visitor deletes them sooner.
Who sets a cookie, and for how long.
Cookies are often described by who sets them and how long they last. Neither tells you on its own whether consent is needed; that depends mainly on what a cookie is used for and the rules that apply.
- First-party cookiesSet under the domain of the website you are visiting. Used for things like sign-in, shopping carts and preferences, and sometimes for analytics or advertising.
- Third-party cookiesSet under a different domain, usually by a service embedded in the page, such as an advertising network, social media widget or video player. Because the same service can appear on many websites, some third-party cookies can recognise a browser across those sites. Some browsers restrict them by default.
- Session cookiesTemporary cookies without an expiry date. Session cookies are usually deleted when the browser session ends.
- Persistent cookiesKept until the expiry date the website sets, unless the website or the visitor deletes them sooner. Some browsers also limit how long certain cookies can last.
Websites can also store or read data with similar technologies, such as local storage and tracking pixels. Privacy rules often treat them the same way as cookies.
The most common cookie categories.
Consent banners often group cookies by purpose, so visitors can choose which categories to allow. The CookieHub Consent Management Platform (CMP) uses four categories: necessary cookies stay on, and visitors can allow or deny preference, analytical and marketing cookies.
- Necessary cookiesNeeded for a website to work, such as keeping a visitor signed in, remembering items in a shopping cart or balancing load across servers. Whether a cookie counts as necessary depends on its actual purpose, not on its label.
- Preference cookiesRemember information that changes how a website looks or behaves for each visitor, such as their preferred language, region, currency or colour theme.
- Analytical cookiesNot essential to the service itself, but show how a website is used, so issues can be found and useful content improved. The data is often aggregated, but some analytics technologies may collect information that can identify a visitor.
- Marketing cookiesUsed to understand visitors’ interests and support advertising. They may be set by the website itself or by third-party advertising services.
- NecessaryAlways onRequired for the site to work.
- PreferencesRemembers settings such as language.
- AnalyticsHelps measure how the site is used.
- MarketingUsed to personalise advertising.
When cookies may need consent.
Privacy laws don’t treat all cookies the same way. Whether consent is needed depends on a cookie’s purpose, the rules that apply to your visitors and whether an exemption applies.
GDPRePrivacy DirectivePrivacy regulations- European Union and EEAePrivacy rules, set by the ePrivacy Directive and each country’s national law, generally require consent before storing or accessing non-essential information on a visitor’s device, subject to limited exemptions. Where consent is relied on, the GDPR sets the standard for valid consent: freely given, specific, informed and unambiguous.
- Strictly necessary cookiesGenerally do not require consent under ePrivacy rules when they are strictly necessary to provide a service the visitor explicitly requested, such as a shopping cart. Many websites still list them in their cookie declaration.
- Analytics, marketing and preference cookiesIn the EU and EEA, these often require consent before they are stored or accessed, depending on their purpose and the applicable national rules. Some regulators allow limited exemptions, for example for certain audience measurement.
- Other regionsApproaches outside Europe vary. Some laws, such as the CCPA in California, focus on notice and the right to opt out rather than prior consent, while others require consent in some situations. Requirements differ by country and state.
This page is general information, not legal advice. Check the rules that apply to your visitors.
Where consent management fits in.
A consent management platform helps you find the cookies your website uses, collect visitors’ choices and apply them to cookies and scripts, based on the setup you choose.
Cookie scanner
Find the cookies and services your website uses, with suggested categories you can review.Cookie declaration
Show visitors a list of the cookies your website uses, built from the cookie data you review and publish.Consent management
Collect visitor choices for the cookie categories you set up, and apply them to cookies and scripts.Privacy Policy Generator
Create a privacy policy that explains how your website handles personal data.
Questions about cookies, answered.
A cookie is a small piece of data that a website stores in your browser. It helps the site remember information between pages and visits, such as whether you are signed in or what is in your shopping cart.
Cookies are small pieces of data, not programs, so they can’t run code or install malware on a device. The main privacy concern is tracking: some cookies can be used to follow what visitors do across visits or websites, for example to understand their interests for advertising. Many cookies, such as those that keep you signed in, aren’t used for tracking.
First-party cookies are set under the domain of the website you are visiting. Third-party cookies are set under a different domain, usually by an embedded service such as an advertising network or social media widget. Because the same service can appear on many websites, some third-party cookies can recognise a browser across those sites.
Not necessarily. It depends on what a cookie is used for, which rules apply to your visitors and whether an exemption applies. In the EU and EEA, cookies that are strictly necessary for a service the visitor explicitly requested generally don’t need consent, while analytics and marketing cookies often do. Other regions take different approaches, so check the regulations that apply to your visitors. Explore privacy regulations by region
Session cookies are usually deleted when the browser session ends. Persistent cookies are kept until the expiry date the website sets, unless the website or the visitor deletes them sooner. Some browsers also limit how long certain cookies can last.
Run a free scan of your homepage with Cookie Checker for a quick look, or use the CookieHub cookie scanner to crawl your website. It suggests a category for the cookies it recognises, you review the results in the dashboard, and it rescans on your plan’s schedule. Cookie Checker Cookie scanner
Yes. Browsers let people delete cookies and block some or all of them in their settings, although blocking cookies can stop some website features from working. On websites with a consent banner, visitors can usually also allow or deny optional cookie categories and change their choice later.
See which cookies your website sets.
Scan your website for free, then see how consent management helps you collect and apply visitor choices where applicable.