What are cookies and how do they work?
Cookies are a small piece of data sent from a website and stored in the user’s web browser while the user is browsing it.
- server name from whitch the cookie was sent;
- cookie lifetime;
- value – usually random generated unique number.
Every time the user loads the website, the browser sends the cookie back to the server to notify the user’s previous activity.
Cookies were designed to be a reliable mechanism for websites to remember stateful information (such as items added in the shopping cart in an online store) or to record the user’s browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past). Cookies can also store passwords and form content a user has previously entered, such as a credit card number or an address.
- Session cookie, also known as an in-memory cookie or transient cookie, exists only in temporary memory while the user navigates the website. Web browsers normally delete session cookies when the user closes the browser. Unlike other cookies, session cookies do not have an expiration date assigned to them, which is how the browser knows to treat them as session cookies.
- Persistent cookies: instead of expiring when the web browser is closed as session cookies do, persistent cookies expire at a specific date or after a specific length of time. This means that, for the cookie’s entire lifespan (which can be as long or as short as its creators want), its information will be transmitted to the server every time the user visits the website that it belongs to, or every time the user views a resource belonging to that website from another website (such as an advertisement).
- 1st party cookie‘s domain attribute will match the domain that is shown in the web browser’s address bar and can be permanant or temporary. Websites use this cookies for storing information, that will be used again, when a user visits this website.
- 3rd party cookies however, belong to domains different from the one shown in the address bar. These sorts of cookies typically appear when web pages feature content, such as banner advertisements, from external websites. This opens up the potential for tracking the user’s browsing history, and is often used by advertisers in an effort to serve relevant advertisements to each user.