What is "cookies"
Cookie (literally: cookie), connection testimony, or simply testimony is a group of data exchanged between the browser and the page server, placed in a text file (file) created on the user’s computer. Its main function is to maintain the persistence of HTTP sessions. The use and implementation of cookies was an addendum to HTTP and much debated at the time of the concept, introduced by Netscape, due to the consequences of keeping confidential information on a computer - as it may sometimes not be properly secure, as the usual use in public terminals.
An example is that cookie that a website creates so you don’t have to enter your password again when you go to the site again. Other sites may use them to store user preferences, for example when the site allows you to choose a background color for your pages.
Functioning:
- When the server wants to activate a cookie on the client, it sends a line in HTTP header initiated by Set-Cookie: ...
- Thereafter, depending on the options specified by cookie, the client will send in its HTTP header of the requests a line containing the relevant cookies, initiated by Cookie: ....
Among the cookie parameters are: the lifespan (the date for the cookie to "expire") and the domain, or group of pages to which the cookie applies. For example, it is possible to make a cookie apply only to addresses initiated by http://pt.wikipedia.org/wiki/ so that same cookie no longer applies to http://pt.wikipedia.org/skins/, for example.
If the expiration date for the cookie is not specified, it will expire as soon as the user closes the browser.