What cookies are and what they do
A cookie is a small file that a website stores on your computer or phone. When you visit that website again, your browser sends the cookie back to it automatically. Websites use cookies to remember things about you — your login information, items in your shopping cart, your language preference, or which articles you have read.
Cookies are not programs and cannot harm your device by themselves. They are plain text files, usually a few kilobytes in size. A cookie might contain your username, a session ID, or a timestamp. The website that created the cookie is the only one that can read it — a cookie from Amazon cannot be read by Google.
Without cookies, you would have to log in to every website from scratch each time you visit. You would lose your shopping cart if you closed the browser. Websites would have no way to remember your preferences. Cookies solve this by letting websites store small pieces of information on your device.
Key Takeaways
- Cookies are text files websites store on your device to remember information about you, such as login details or shopping cart contents.
- First-party cookies come from the website you are visiting, while third-party cookies come from advertisers or analytics companies embedded in that site.
- Session cookies disappear when you close your browser, while persistent cookies remain on your device until they expire or you delete them.
- You can see what cookies are stored, delete them, or block new ones from being created through your browser settings.
- Websites must disclose their cookie use and get your consent in many countries, though the rules vary by location.
First-party cookies versus third-party cookies
A first-party cookie is created by the website you are visiting. When you log into your email, the email provider sets a cookie so it knows you are logged in. When you add items to a shopping cart, the store sets a cookie to remember what you picked. These cookies are necessary for the website to function the way you expect.
A third-party cookie is created by a different company — usually an advertiser or analytics service — whose code is embedded in the website you are visiting. For example, a news site might use Google Analytics to track how many people visit each article. Google sets a cookie on your device to track your movement across that site and others. Facebook's tracking pixel works the same way, following you across multiple websites to build a profile of your interests.
Third-party cookies are why you see ads for something you looked at on one website when you visit a completely different site. An advertiser uses cookies to follow you across the web and show you targeted ads. This is also why many people find third-party cookies more intrusive than first-party ones — you did not choose to interact with the advertiser directly.
Session cookies and persistent cookies
A session cookie exists only while your browser is open. When you close the browser window or tab, the cookie is deleted. Session cookies are often used for login information or temporary preferences during a single visit. They do not clutter your device because they disappear automatically.
A persistent cookie stays on your device after you close the browser. It has an expiration date set by the website — it might last a few days, a few months, or even a year. Persistent cookies are used for things like remembering your username so you do not have to type it in next time, or storing your language preference. When the expiration date arrives, your browser deletes the cookie automatically.
You can also manually delete persistent cookies at any time through your browser settings. Clearing your browser history usually deletes cookies as well, depending on which options you choose.
How to view and manage cookies in your browser
Every major browser lets you see what cookies are stored and delete them. In Chrome, open Settings, go to Privacy and Security, then Site Settings, then Cookies and Site Data. You will see a list of websites that have stored cookies on your device. You can delete all cookies at once or remove cookies from specific websites.
In Firefox, go to Settings, Privacy and Security, scroll to Cookies and Site Data, and click Manage Data. Safari users go to Preferences, Privacy, and Manage Website Data. Edge follows the same path as Chrome since it uses the same engine.
You can also block cookies before they are created. Most browsers let you choose between allowing all cookies, blocking third-party cookies only, or blocking all cookies. Blocking all cookies will break many websites — you will not be able to stay logged in, and shopping carts will not work. Blocking third-party cookies is a middle ground that keeps websites functional while reducing tracking.
Why websites ask for cookie consent
In the European Union, the ePrivacy Directive requires websites to get your permission before storing cookies on your device. The United States does not have a single federal law, but California's Consumer Privacy Act and similar state laws have created similar requirements. Many websites now show a cookie consent banner when you first visit, asking whether you accept cookies.
These banners often make it easy to accept all cookies but harder to refuse them. Some sites bury the "Reject All" button or make it smaller than the "Accept All" button. This practice is called dark patterns. A few countries have started cracking down on it, requiring that rejecting cookies be just as easy as accepting them.
The banner usually explains what cookies the site uses and why. First-party cookies for login and shopping are almost always necessary. Third-party cookies for advertising and analytics are usually optional — you can refuse them and the site will still work, though you may see non-targeted ads instead.
Privacy concerns and cookie tracking
Cookies themselves are not inherently dangerous, but they can be used to track you across the web in ways you might not expect. A third-party cookie from an ad network can follow you from a news site to a shopping site to a social media platform, building a detailed profile of your interests, location, and behavior. This profile is then sold to advertisers or used to show you targeted ads.
Some people find this tracking invasive. Others do not mind targeted ads in exchange for free content. The concern is that you usually do not know exactly what data is being collected or how it will be used. A cookie might contain your approximate location, your device type, the articles you read, or the products you looked at.
Browsers are slowly moving away from third-party cookies. Google has announced plans to phase out third-party cookies in Chrome, though the timeline has shifted multiple times. Safari and Firefox already block third-party cookies by default. This does not mean tracking will stop — companies are developing new methods — but it does mean the old cookie-based system will become less common.
Frequently Asked Questions
Can cookies steal my passwords or personal information?
A cookie cannot access information that was not put into it. If a website stores your password in a cookie, that is a security flaw on the website's part — most do not. Cookies cannot read your files, see your camera, or access other websites' cookies. They are confined to the website that created them.
What is the difference between cookies and tracking pixels?
A tracking pixel is a tiny invisible image embedded in a website or email. When you view the page or open the email, your browser downloads the pixel, and the company that owns it learns you visited or opened it. Pixels do not store data on your device the way cookies do, but they serve a similar purpose — tracking your behavior across the web.
If I delete my cookies, will websites know I deleted them?
No. Websites cannot tell whether you deleted cookies or never accepted them in the first place. They will simply treat you as a new visitor the next time you arrive. You may have to log in again or re-enter preferences, but the website will not penalize you for deleting cookies.
Do I need to delete cookies regularly?
Not necessarily. Cookies take up very little space on your device. Deleting them regularly will not improve your computer's performance. You might delete cookies if you are concerned about privacy, if you share a device with others, or if a website is not working properly. Otherwise, leaving them alone is fine.
Why do some websites not work when I block all cookies?
Many websites rely on session cookies to keep you logged in or to remember your shopping cart. If you block all cookies, these features stop working. The website will still load, but you will not be able to use it normally. This is why most people block only third-party cookies instead of all cookies.