On this page
Types of cookies website owners should know
Every cookie on your site can be described in three ways at once. A Google Analytics cookie, for example, is first party, persistent and used for statistics. Each label answers a different question:
| Sorted by | Types | Question it answers | Decides consent? |
|---|---|---|---|
| Who sets it | First party, third party | Which domain does the cookie belong to? | No |
| Lifetime | Session, persistent | Is it deleted when the browser closes, or does it stay? | No |
| Purpose | Necessary, preferences, statistics, marketing | What is it for, and does the visitor need it? | Yes |
A lot of confusion comes from mixing these up. A first-party cookie is not automatically exempt, and a session cookie is not automatically harmless. Under the EU ePrivacy Directive, storing information on a visitor's device needs consent unless it is strictly necessary for a service the visitor asked for. That is a test of purpose, not of domain or lifetime.
First party vs third party cookies
The difference is the cookie's domain compared with the site in the address bar.
- First-party cookies belong to the site the visitor is on. On example.com, a cookie set for example.com or www.example.com is first party.
- Third-party cookies belong to another domain, usually through an embed, an ad tag or a tracking pixel that loads from that domain. A cookie set for an ad network's domain while the visitor reads your page is third party.
Browsers treat the two differently. Safari and Firefox block many third-party cookies by default. First-party cookies still work, and that is why many analytics and ad tools now set their cookies on your own domain.
Can a third-party script set first party cookies?
Yes, and it happens all the time. When you add Google Analytics, Google's script runs on your page and writes the _ga cookie for your domain. The Meta Pixel does the same with _fbp. Both are first-party cookies by domain, but they serve another company's statistics or advertising.
Domain is not ownership. When you classify a cookie, ask which script set it and why. The domain alone will not tell you whether it needs consent.
Session cookies vs persistent cookies
This split is about lifetime, and it is set by the cookie itself. The MDN guide to HTTP cookies covers the attributes in detail.
| Session cookies | Persistent cookies | |
|---|---|---|
| How it is set | No Expires or Max-Age attribute | Has an Expires date or a Max-Age |
| When it goes away | When the browser session ends | At its expiry date, or when the visitor clears it |
| Typical use | Login session, checkout steps, load balancing | Remembered language, analytics IDs, ad IDs, a saved consent choice |
One catch: browsers that restore the last session on startup can keep session cookies alive for days. Never rely on "it is only a session cookie" as your reason for skipping consent. A session cookie that tracks a visitor for analytics still needs consent. A persistent cookie that keeps a visitor signed in may still be necessary. In your cookie policy, the lifetime goes in the expiry column, not the category.
Which cookie categories need consent?
Most consent tools and cookie policies use four purpose categories. These are the ones a visitor sees in the banner's settings and the ones your cookie declaration is grouped by.
| Category | What it is for | Common examples | Consent |
|---|---|---|---|
| Necessary | Things the site cannot work without for a service the visitor asked for | Login session, shopping cart, security tokens, the stored consent choice | Not needed |
| Preferences | Remembering choices and running optional features | Language or region choice, chat widgets | Needed |
| Statistics | Measuring how the site is used | Google Analytics, Hotjar, Microsoft Clarity, Matomo Cloud | Needed |
| Marketing | Advertising, retargeting and conversion tracking | Google Ads, Meta Pixel, LinkedIn Insight, TikTok Pixel, YouTube embeds | Needed |
Necessary cookies: the only exempt category
Keep this category small. A cookie is necessary when removing it would break something the visitor asked for, such as staying signed in or keeping items in a cart. It is not necessary just because it is useful to you. Our guide to strictly necessary cookies has a four-question test for borderline cases.
What are functional cookies?
"Functional" is a label, not a legal category, and tools use it in different ways. Usually it means preference cookies: they remember a language, a region or a layout choice, or they power an optional feature like a chat widget. Some vendors also use "functional" for cookies that are really necessary. Judge each cookie on its own. If the site works for the visitor without it, it belongs under preferences and waits for consent.
Statistics cookies
Analytics cookies count visits, sessions and returning visitors. They are almost always persistent and often first party. Under EU rules they need consent like any other non-essential cookie.
What are marketing cookies?
Marketing cookies identify a browser so ads can be targeted, measured or shown again on other sites. Conversion pixels, retargeting tags and social embeds belong here. A YouTube embed counts too, because it sets cookies as soon as it loads. These cookies carry the most risk, and in California they can also count as "sharing" under the CCPA. See CCPA cookies for the opt-out side.
Cookies vs local storage: do the same rules apply?
Technically they are different. Legally they are treated the same way.
| Cookies | Local storage | Session storage | |
|---|---|---|---|
| Sent to the server | With every matching request | Never, read by scripts only | Never, read by scripts only |
| Lifetime | Session or until expiry | Until cleared | Until the tab is closed |
| Scope | Domain and path | One origin | One origin, one tab |
| Needs consent if non-essential | Yes | Yes | Yes |
The ePrivacy rule covers storing or reading any information on the visitor's device, so it does not matter whether a tracker uses a cookie or a key in the Web Storage API. Many analytics and session-replay tools use both. Give storage keys the same four categories and list them in your cookie policy too.
How to classify a cookie you do not recognize
A name like _ga is easy to place. Something like sid_v2 or hx_pref is not. Work through it in this order:
- Check the domain. If it belongs to another company's domain, it came from an embed, tag or pixel. Find which one loads from that domain.
- Look up the name. Well-known prefixes point to their vendor:
_gaand_gidto Google Analytics,_gcl_auto Google Ads,_fbpto the Meta Pixel,_hjto Hotjar. - Find what sets it. In your browser's developer tools, open the network panel and reload the page in a private window. A
Set-Cookieheader in a response shows which request set it. If no header sets it, a script did. Search your theme, plugins and tag manager for the name. - Ask what breaks without it. Delete the cookie and use the site. If login, cart or checkout stops working, it is likely necessary. If nothing the visitor asked for changes, it is not.
- Pick the category from the purpose, then make the script that sets it wait for that category.
When in doubt, do not call it necessary. A cookie filed as necessary runs before any choice. Putting a tracker there is the classic mistake regulators look for.
How a scan classifies your cookies
A CookieRule cookie scan opens your site in a real browser and lists every cookie, local storage key, session storage key and known tracker request it finds. It visits twice: once as a new visitor and once after choosing Allow All. A cookie found only on the second visit is marked Set only after consent, which tells you its tag already waits.
Each item then shows one of these:
- A category with "Our classification": the cookie database recognized it by name and domain and filled in the vendor, purpose and retention.
- Yours to classify: an unknown cookie set by your own site. Only you know what it does, so set its category with the pencil button.
- Being identified: an unknown cookie set by another company. It is added to the database once it is known, and you do not need to act.
Your own category always wins over ours and applies only to your websites. Cookies still without a category appear under Unclassified in your cookie declaration and are treated as needing consent.
Does classifying a cookie block it?
No. Classifying sets the label your visitors and your declaration see. Blocking happens per script. Once you know which script sets a cookie, tag that script with its category so it waits for consent:
<script type="text/plain" data-consent="statistics" src="https://analytics.example.com/tracker.js"></script>Common vendors such as Google Tag Manager, the Meta Pixel and Hotjar are also held back automatically. Any other script runs as normal until you tag it. The blocking scripts guide covers inline scripts, iframes and pixels.
Ready to see which types of cookies your website sets?
- Every cookie and storage key listed after a real browser visit
- Vendor, purpose and retention filled in for known cookies
- Unknown cookies from your own site marked for you to classify
Frequently asked questions
Cookies are sorted three ways: first party or third party by who sets them, session or persistent by lifetime, and necessary, preferences, statistics or marketing by purpose. Every cookie has one label from each group. Only the purpose decides whether you need the visitor's consent before setting it.
A first-party cookie belongs to the domain in the address bar. A third-party cookie belongs to another domain, usually through an embed or ad tag. Third-party scripts often set first-party cookies too, as Google Analytics does with _ga. So the domain alone does not tell you whether consent is needed.
A session cookie has no expiry date and is deleted when the browser session ends. A persistent cookie has an Expires date or Max-Age and stays until then, unless the visitor clears it. Lifetime goes in your cookie policy's expiry column. It does not decide consent: a session cookie used for tracking still needs it.
Functional cookies usually means preference cookies. They remember a visitor's language or region, or they run optional features like chat widgets. The term is not a legal category, and some tools use it for necessary cookies too. If the site works without the cookie, treat it as preferences and wait for consent.
Check its domain, look up its name, then find what sets it with your browser's network panel or by searching your code and tag manager. Delete it and see if anything the visitor asked for breaks. Pick the category from its purpose, then tag the script that sets it so it waits for consent.