Cookie guide

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.

What are cookies

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 cookies work

How a cookie is set and read.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

First-party and third-party cookies

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.

Cookie categories

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.
See how a cookie declaration lists them
Cookie preferencesexample banner
  • NecessaryAlways onRequired for the site to work.
  • PreferencesRemembers settings such as language.
  • AnalyticsHelps measure how the site is used.
  • MarketingUsed to personalise advertising.
Consent stateNecessary · Preferences · AnalyticsUp to date
FAQ

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.

Next step

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.