If you give a browser a cookie, it will give you all of your personalized settings.
Imagine trying to check your email or browsing through youtube and every single time that you navigated from one page to another you were forced to login again. Or how you would be able to shop online without having the option to store things in your cart. Those basic features that are essential for anyone trying to use the internet are possible thanks to cookies. A cookie is a small baked treat loved by humans and mouses alike, a cookie is also a piece of data stored on a computer that can be accessed by a web server. Lou Montulli the inventor of cookies named them after ‘magic cookies’ a popular term used by unix programmers.
HTTP Protocol
HyperText Transfer Protocol (HTTP) is the universally agreed upon method used for exchanging data on the web. HTTP request are usually initiated by the client and the protocol defines how the response from a web server will be formatted. HTTP is also stateless. This means that there is no information retained by the sender or receiver. The client is unaware of the state of the server and vise versa. And even though multiple request can be sent over the same connection they are all still separate requests. Each packet must contain enough information to fulfill their own request and the receiver does not attach any special meaning to multiple request arriving over the same socket. HTTP protocol was designed this way to minimize the time and bandwidth it would require to re-establish a connection for each incoming requests. In order to have stateful communication between a client and server web developers create a program that the server can call that stores state information.
Use Cases
There are many different reasons that a site may ask users to accept cookies. The most common reasons are for authentication and e-commerce. Secure sites need to be able to validate a user’s identity as they peruse through all of the different pages of a site. And cookies are an essential part of e-commerce, it would be nearly impossible to shop online if you were unable to store items in a shopping cart. Cookies can also be used to track what pages a user has visited, sites use this with the intention of better understand their users and providing a more tailored experience for each user. The use of cookies allows users to have a more simple online experience, by remembering login information, empowering sites to give better product recommendations, and remembering previously set settings.
Session vs Permanent
There are two main types of cookies session cookies and permanent cookies. They both do exactly what the name implies. Session cookies also known as transient cookies are most commonly used by e-commerce sites. The transfer of this data is between your browser and temporary memory. These cookies expire at the end of a session or once you close your browser. They allow you to store things in your cart while you navigate through a site all the way up to checkout. Session cookies are created by not setting an expiration date when a program creates a cookie.
Permanent cookies also referred to as persistent or stored cookies are stored in a user’s hard drive until the expiration date that is set when a cookie is create or until a user deletes it. Persistent cookies are used for things like remembering ones login details so you don’t have to type them in every time you visit a site.
Privacy Concerns
While cookies are inherently harmless, there is a lot of public concern and misinformation surrounding the use of one’s data and general privacy related to cookies. It’s important to know that permanent cookies are simply stored in one’s hard drive. Servers are only able to access information from the cookie it stored data in. These cookies do not have access to any other part of your hard drive and are only able to access data from their own domain. They are also unable to access other cookies stored on a user’s computer. Client’s have full control of the cookies stored on their computers, they are able to delete them at any time, there is also third-party software available to automatically block cookies. The disadvantage of this is many websites do require the use of cookies for many different reasons such as authentication.
Essentially, cookies are to thank for the personalized experience we have using the web every single day.