Skip to content

What Are the Three Types of HTTP Cookies?

HTTP cookies fall into three practical categories based on how long they live and which domain places them.

OUTPUT FORMATSHTMLJSONMarkdown

This guide explains each category, then gives you a short checklist for sorting any cookie you encounter.

The three cookie categories at a glance

The three types of HTTP cookies are session cookies, persistent cookies, and third-party cookies. Each is defined by a different combination of lifetime and setting domain.

  • Session cookies are temporary. They live in the browser's memory only while the user is on the site, and they are deleted when the browser closes.
  • Persistent cookies carry an expiration date. They are stored on the user's device for a set period and survive after the browser is closed. They are also known as first-party cookies.
  • Third-party cookies are set by a domain other than the one the user is visiting. They are also called tracking cookies because they can follow a user's behavior across sites.

A two-question checklist for classifying a cookie

When you need to sort a cookie, ask these questions in order:

  1. Does it have an expiration date? If no, it is a session cookie. If yes, it is a persistent cookie.
  2. Which domain set it? If the setting domain differs from the site the user is visiting, it is a third-party cookie regardless of its lifetime.

Note the naming overlap: persistent cookies are also referred to as first-party cookies, but a cookie can be persistent and still be set by a third party. The domain question is the decisive test for the third-party category.

Worked example: an ad network cookie

Suppose a user visits a news site and sees an ad served by an ad network. The ad network sets a cookie that records the user's behavior so it can show relevant ads later. Because the cookie comes from the ad network's domain rather than the news site's domain, it is a third-party cookie. If that cookie also has an expiration date, it is additionally persistent — the two labels describe different properties and can both apply.

Field map: how the categories differ

The table below summarizes the three categories across the properties that distinguish them.

CategoryLifetimeStorage locationSetting domain
Session cookieUntil browser closesBrowser memoryVisited site
Persistent cookieUntil expiration dateUser's deviceVisited site (first-party)
Third-party cookieVariesUser's deviceA domain other than the visited site

Use the lifetime column to separate session from persistent, and the setting-domain column to identify third-party cookies.

Frequently asked questions

Are persistent cookies the same as first-party cookies?

Persistent cookies are also known as first-party cookies in common usage. However, the two labels describe different properties: 'persistent' refers to lifetime (the cookie has an expiration date), while 'first-party' refers to the setting domain (the visited site). A cookie can be persistent and still be set by a third party.

When is a session cookie deleted?

A session cookie is stored in the browser's memory only while the user is on the website. It is deleted once the user closes the browser.

Can a cookie be both persistent and third-party?

Yes. The categories describe different properties. A cookie set by a third-party domain can also carry an expiration date, making it persistent as well as third-party.