Cookies
Published: 2022-12-12 07:07:36


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ial7l55omfi3hkqpa5d.gif)

Before I started learning Rails at the Flatiron School, I wondered what cookies were as they applied to the internet. I remember being able to clear cookies in my browser as a kid, never really understanding how they worked until now.

## Cookies

So what is a cookie? A cookie is a small file stored in our browser and accessed by various websites to store information about the user. For example, you may click a checkbox for a website to keep you logged in. The website's server will then use the cookie to authenticate that you are the user that asked to remain logged in. You may be shopping on a website, and your computer crashes. With cookies, the website's server can retrieve your shopping cart based on the information in the cookie. When you log back on to the website, your shopping cart is still loaded.

Cookies are domain-specific, and the browser stores them for the domain during the session. Without cookies, we would have to submit a user name and password for every request from the server. Have you ever tried to buy something online, only to find that ads for the item pop up as you continue to surf the internet? Cookies. The United States of America is much more lenient about using cookies than the European Union. You are free to use cookies however you want, but depending on how we use them will determine future laws.

## History of the web cookie🍪 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dlw6nj0he9de9b1f1l5.jpeg)
In 1994, computer programmer Lou Montulli, who worked for Netscape Communications, invented the cookie. An extensive online retailer had an issue in that each one of their servers was overloaded with user shopping cart data. Luckily Lou had the solution to this problem, and thus the cookie was born. Instead of filling the online retailer's servers with user shopping cart data, why not fill each user's computer with this data? This saved server space and money for the retailer. 

## Facts about Cookies

- Cookies are stored in your web browser

- Due to European laws, domains must notify a user if a domain is actively using cookies.

- Cookies may expire, and the user can manipulate the data

- A user may set their browser to decline cookies
- Cookies are not a significant security concern. They do not cause harm to your computer in any way. For many users, privacy concerns are more inherent.
- If a cookie does not contain an expiration date, the browser will delete them at the end of a session.
- Most cookies last for up to 30 days. Some cookies last beyond a year.

## Session Cookie

A session cookie is a type of cookie set to expire at the end of a browsing session. This cookie is stored then stored in a browser's memory. These are the safest forms of cookies.

##Persistent Cookie

This cookie is not stored in the browser's memory but on our hard drives. Cookies of this nature persist in our computers until their expiration and are not as safe as session cookies.

## Third-Party Cookies
Third-party domains create third-party cookies. Advertisers can reach more clients with the use of this style of cookie. In addition, you may receive relevant advertisements as you browse the internet about that item. Like persistent cookies, third-party cookies remain on a computer's hard drive until they expire.

In conclusion, not all cookies are for advertising, sales, or privacy breaches. Many cookies are created to give users a better and faster experience on the web. Cookies allow us more automation and save us time on the internet.