Web cookies often have a negative connotation. In reality, they are indispensable tools for websites and sometimes save you time. In this article, we will look at how cookies work, the different types of cookies, what benefits they can bring to your website or the regulations concerning them... In a next article we will see how to implement them in our web page code.
Since the creation of cookies, many rumors have developed:
- Cookies are like viruses, they infect users' hard drives.
- Cookies are used to send spam.
- Cookies are used only for advertising.
We will see in this article that all these rumors are false.
How it works ?
A web cookie is defined by the HTTP communication protocol as a small text sent by an HTTP server to an HTTP client, which the latter will send back the next time it connects to servers sharing the same domain name. It consists of a text containing an arbitrary sequence of key-value pairs. It is stored on the client's computer for a specific period of time.
For example, if you log in to a website and don't want to log in the next time, sometimes you can check the box "keep my session active" or "remember me". In this case, one or more cookies are created and stored on your computer to automatically log you in the next time you access that website. The cookies can be the following:
- nickname : mypseudo
- password : azerty
(In reality the password cookies are often encrypted, for security)
A bit of history
Now we can ask ourselves how long have cookies been around ?
The term cookie is a derivation of magic cookie. In programming, a magic cookie is a packet of data that a program receives and sends back unchanged. In 1994, Lou Montulli, an American computer scientist, had the idea of using cookies for client-server exchanges on the Web. At the time, he was an employee of Netscape Communications, a company developing Web browsers.
After being implemented in the Netscape 0.9 beta Web browser in 1994, cookies were integrated into Internet Explorer 2, released in October 1995.
Cookies were accepted by default in browser settings, and users were not informed of their presence. The general public only learned of their existence after the Financial Times published an article on February 12, 1996. That same year, cookies received a lot of media attention because of possible privacy intrusions.
From the end of 2014, we see a banner about cookies on many sites. Depending on the country and continent, the regulations are not the same.
Why they have a bad reputation ?
So why do they have such a bad reputation ?
On the one hand, cookies are stored on the customer's computer and therefore take up storage space. Even if it is often tiny, the accumulation of cookies can end up weighing a real weight in the storage of the device.
On the other hand, as we have seen before, they can be an intrusion of privacy. Indeed, other types of cookies, called third-party cookies, can track users through the different sites they visit. For example, some advertising companies can track users across all pages where they have placed advertising images or a spy pixel. The knowledge of the pages visited by the user allows the advertising companies to target the user's advertising preferences.
The ability to build a user profile is considered by some to be an invasion of privacy, especially when tracking is done through different domains using third-party cookies. For this reason, some countries have cookie legislation.
To be in order
To be sure to comply with regulations, it is best to set up a cookie banner warning users. Ideally, the user can either accept all cookies or manage their preferences.
To save time when developing websites, many developers use cookie consent libraries. This way, their site follows the legislation, without requiring a large development effort.
For my part, I use this library, developed by myself 😆. It is very easy to use, and offers a clean and customizable banner for your website. To understand how it works, just read the github documentation. I will make an article detailing it later.
clement-gaudiniere / librairie-cookie-consent
This easy-to-use library allows you to ask your users for feedback on various parameters that can be set directly in the code. For more information, see the README file.
Because the users' agreement counts.
This easy-to-use library allows you to ask your users for feedback on various parameters that can be set directly in the code. For more information, see the README documentation. IMPORTANT NOTE: for use with jQuery.
If you want to see the result directly, download the latest release, and go to the Example folder. Then run the index.html file. You can see below the popup of the library, below, of course, the style is fully configurable in the CSS document
How to install it ?
You can download the entire library in three different ways:
- via the library-cookie-consent release page.
- via NPM :
npm install librairie-cookie-consent
- via Bower : Not yet available
How to use it ?
Before starting any manipulation with the library, the CSS file
popupConsent.css, the file
popupConsent.min.js, and the jQuery framework must be…
I hope you learned something about cookies, feel free to ask me any questions you may have. 👍
You want to support me ?
Top comments (0)