Cookies may sound like a dessert to you but it is an important thing on the web. Cookies ( also known as internet cookie or HTTP cookie) are small files of information that a web server generates and sends to a web browser whenever you visit any website or access the internet. It is a small message from a web server passed to the user’s browser when you visit the website. Web browsers store the cookies they receive from the web server and attach the relevant cookies to any future requests the user makes of the web server. This is done to enhance the user’s experience on the web. Where are cookies stored Cookies are stored in the user’s device. Depending on different browsers and platforms, they are stored in different locations. For instance, in google chrome, cookies are found in developer tools > Network tab > Storage > Cookies (on the left side ). What are cookies used for Whenever you visit a website, the server will send some data in the form of cookies to the web browser. Web Browser will then store the cookies and use it to create a more personalized view/experience for the user. Cookies are commonly used for personalization, tracking, information about user sections, user preferences, and other data on the website. Cookies help websites remember users data and track their activities in order to personalize their experience in a better way. User sessions: Cookies help associate website activity with a specific user. A session cookie matches a user’s session with the relevant data and content for the user. For instance, suppose you have an account on a website. So whenever you log into your account, the server will generate a user session and send it to your browser. This cookie will tell your browser to load your account’s content on the homescreen. If you click on a product page displaying a Laptop. When your web browser sends an HTTP request to the website for the laptop product page, it includes your session cookie with the request. Because the website has this cookie, it recognizes you, and you do not have to log in again when the new page loads. Personalization: Cookies help a website "remember" user actions or user references, enabling the website to customize the user's experience. For eg. if you search for a particular product on an ecommerce website, then you get related products in the suggestions. This happens because the website has stored your activity data in the cookie and then suggests more products related to this. Tracking: Some cookies are used to record what websites users visit. This information is sent to the server that originated the cookie the next time the browser has to load content from that server. With third-party tracking cookies, this process takes place anytime the browser loads a website that uses that tracking service. For eg. if you search for something on google, then you may get to see the ads of the similar product on any social media platform. This happens because their third party cookies are stored on google and they are tracking what websites you are visiting. However, advertising is not the only use for tracking cookies. Many analytics services also use tracking cookies to anonymously record user activity. Types of Cookies Session cookies: A session cookie helps a website track a user's session. Session cookies are deleted after a user's session ends — once they log out of their account on a website or exit the website. Session cookies have no expiration date, which signifies to the browser that they should be deleted once the session is over. Persistent cookies: Unlike session cookies, persistent cookies remain in a user's browser for a predetermined length of time ( generally less than 6 months ). Persistent cookies are commonly used for long term tracking and remembering user preferences. Zombie cookies: Unlike a standard cookie, zombie cookies can be stored in multiple locations with backups in the browser. Zombie cookies can regenerate after they are deleted. Zombie cookies create backup versions of themselves outside of a browser's typical cookie storage location. They use these backups to reappear within a browser after they are deleted. Zombie cookies are sometimes used by fraud ad networks, and even by cyber attackers. First-party cookies: First-party cookies are set by the website that you are currently visiting. First-party cookies are generally used to provide a good user experience, collect the analytics data, remember language settings etc. Third-party cookies: Third-party cookies are set by the domains that you are not visiting. Third-party cookies are mostly used for cross-site tracking and advertising purposes. These cookies collect data about your browsing habits and serve ads according to it. For example, when you visit a website, it may include content (such as ads or social media widgets) from third-party domains. These third-party domains can set cookies on your browser to track your online activity and build profiles for targeted advertising or analytics. Why Cookies are used: Persistence: Cookies can be persistent or session-based, which will be dependent on time duration of the data to last. Key-Value Storage: Cookies store data in a key-value pair which makes it easy to retrieve and update data. For eg. username - your_name Security: Cookies are secure and use features like HTTP and secure attributes to protect against unauthorized access. When to use cookies: Cookies are used for the following mentioned reasons: To store user preferences and settings. To implement authentication and session management. To track user behavior for analytics. To customize the user experience How do cookies affect privacy Cookies can have both positive and negative effect on privacy: Positive: Cookies can enhance user experience by remembering and login information, making websites more user friendly. / Negative: Cookies can raise privacy concerns when they are used for tracking and profiling without user consent. Excessive tracking can lead to online privacy breach and potential for data misuse. Author Ritesh Jindal