What Are Cookies?
Cookies are small text or data files that websites and apps store in a user’s browser or device to remember information about their activity. For instance, browser cookies are used to store specific details about the user, such as their login information and browsing preferences.
For example, the cookie below stores a user’s information in the browser. This allows the website to recognize the visitor and remember their preferences:
user_id=12345; expires=Wed, 24 Jun 2025 12:00:00 UTC; path=/; domain=.example.com; Secure; HttpOnly
In the above cookie:
user_id=12345
indicates the unique identifier used to recognize the userexpires=Wed, 24 Jun 2025 12:00:00 UTC
specifies the cookie’s expiry datedomain=.example.com
specifies the domain and subdomains for which the cookie is validpath=/
indicates the URL path for which the cookie is valid (/
means it is valid for all pages)Sicher
means the cookie is only sent over HTTPSHttpOnly
means the cookie is not accessible via JavaScript (This helps to prevent cross-site scripting (XSS) attacks)
The above cookie is an HTTP cookie, also known as a browser cookie. There are also other types of cookies, including flash and zombie cookies.
There are also tracking mechanisms that can behave like cookies but are not technically classified as such. This includes pixel trackers, supercookies, and HTML5 web storage.
Types of Cookies
While HTTP cookies are the most common type of cookie on the web, there are also other types of cookies, classified by their purpose and storage method. This includes:
- HTTP cookies
- Flash cookies
- Zombie cookies
1 HTTP Cookies
HTTP cookies (also called web cookies, internet cookies, and browser cookies) are small text files a web server sends to a user’s browser.
Websites use HTTP cookies to store information about the user’s activity and preferences. This allows the website to remember the user’s details, such as their login status, language settings, and items in their shopping cart.
HTTP cookies are stored on the browser, so when the user returns to the site, the browser sends the stored cookie back to the server to recall those settings or actions.
2 Flash Cookies
Flash cookies, also known as Local Shared Objects (LSOs), are data files stored on a user’s device by websites that support Adobe Flash. These cookies are used to store the user’s settings and preferences and track their activity within the Flash-supported content.
For example, the Flash cookie below stores a user’s volume setting. So, the video player can then use it to set their volume on future visits.
SharedObject.getLocal("userSettings").data.volume = 0.8;
In the above Flash cookie:
userSettings
specifies the name of the Flash cookiedata.volume
Specifies that the volume is set to 0.8
Flash cookies can also be used to save the progress of a game or set ad preferences. However, they have been deprecated and are no longer supported. Therefore, they are no longer widely used and have become rare.
3 Zombie Cookies
Zombie cookies, also known as evercookies, are cookies programmed to regenerate after they have been deleted. These cookies are stored in multiple locations and formats to ensure they can remain on the device after deletion.
For instance, a zombie cookie can be stored in the HTML5 local storage, which is typically used by web applications. It can also be stored as HTTP cookies and Flash cookies. Zombie cookies are often used for tracking.
Importance of Cookies
Cookies are used to personalize websites and apps for users. They can also be used to track the user’s activity on a specific site or app. Some cookies can even follow the user across the web and gather information from the other sites that they visit.
Developers, advertisers, and analytics reporting tools like Google Analytics use these cookies to track user behavior such as the time they spend on the site, the pages they visited, and the links they clicked on.
In the case of personalization, cookies can be used to manage a user’s session on a site. For instance, it can be used to ensure they remain logged into a site they previously logged into, provided the cookie has not been deleted or expired.
Cookies can also be used to store the user’s browser preferences. For example, a site that wants to comply with privacy laws can require its users to select the information they wish to share with it. That way, the browser cookie will save their choices so they do not need to re-enter them on future visits.