An HTTP cookie is a small piece of data, usually no more than 4 KB, that a website stores in your browser. The browser keeps it and sends it back automatically each time you visit that site, according to rules set by the website, such as which pages it applies to and when it expires.
Cookies are used for login sessions, shopping baskets, language settings, analytics, advertising and remembering your cookie consent choices. They make the web convenient, but some of them also track you, and a stolen login cookie can let an attacker into your account.
Types of cookie
- Session cookies have no expiry date and are removed when the browsing session ends, often when you close the browser.
- Persistent cookies have an expiry date and survive restarts until then.
- First-party cookies are set by the website you are visiting.
- Third-party cookies are set by another domain whose content is embedded in the page, such as an advert or widget. They are mainly used for tracking across sites, and many browsers now restrict or block them.
- Essential cookies are needed for the site to work, for example to keep you logged in.
- Non-essential cookies, such as analytics and marketing cookies, usually need your consent.
Watch: what an HTTP cookie is
Why you should clear your cookies regularly
1. Less tracking, more privacy
Clearing cookies breaks long-term tracking and makes it harder for advertisers, or anyone else, to build a profile of what you do online.
2. Lower risk of session hijacking
A login cookie that no longer exists cannot be stolen. Clearing cookies, or simply signing out, ends old sessions so that a stolen token cannot be reused.
3. Fewer website problems
Corrupted or outdated cookies can cause login loops, broken features and pages that will not load properly.
4. Less personal data left behind
Some sites keep details or preferences in cookies. Clearing them stops the next person who uses the device, or malware on it, from picking them up.
Watch: why you should clear your cookies
Good cookie habits
- Accept only necessary cookies. Choose “essential only” or “reject non-essential” on consent banners.
- Block third-party cookies in your browser settings to reduce tracking across sites.
- Clear cookies regularly, and always after using a shared or public computer.
- Sign out of sensitive accounts when you have finished, especially on devices other than your own.
- Use private browsing for quick sessions you do not want stored, remembering that it does not hide your activity from websites or your network.
- Keep your browser updated, as modern browsers add protections against cookie theft.
- Turn on multi-factor authentication (MFA). It will not stop a stolen session cookie, but it stops attackers signing in again with your password once that session ends.
For website owners
If you run a website, store login sessions only in cookies marked HttpOnly (so scripts cannot read them), Secure (sent only over HTTPS) and with an appropriate SameSite setting. Never store passwords or sensitive personal data in cookies, and ask for consent before setting non-essential ones.