DEV Community

Cover image for Wondering about browser cookies? this post for you!
Mohamed A. Othman
Mohamed A. Othman

Posted on

Wondering about browser cookies? this post for you!

Cookies are an essential part of our browsing experience, but not everyone knows what they are exactly. And, there are misconceptions surrounding them, like potential privacy threats or why websites use cookies in the first place.

“This website uses cookies.”

You’ve come across this message many times while surfing the web. Actually, we deal with browser cookies (sometimes without knowing it) way more often than we have real cookies with our morning coffee, But what exactly cookies is? why are websites using cookies? and are they safe? in this post, I will answer all of those questions.

First of all, What are Cookies?

(also called HTTP Cookies or Browser cookies)

A cookie is a string of characters that a website can ask your browser to store. Whenever your browser requests a page from the website, it sends the cookie back. Websites can then use these cookies to remember who you are or to remember certain settings when you move between pages, Like login credentials, identify customers, and provide a customized shopping experience.

So, When are Cookies Created?

Writing data to a cookie is usually done when a new web page is loaded — for example, after a ‘submit’ button is pressed the data handling page would be responsible for storing the values in a cookie. If the user has elected to disable cookies then the write operation will fail, and subsequent sites which rely on the cookie will either have to take a default action or prompt the user to re-enter the information that would have been stored in the cookie.

But, Why are Cookies Used in the first place?

If there is a large amount of information to store, then a cookie can simply be used as a means to identify a given user so it’s more like a user’s footprint that can be tracked. For example, the first time a user visits a site they may choose a username which is stored in the cookie, and then provide data such as password, name, address, preferred font size, page layout, etc. — this information would all be stored on the database using the username as a key.

Then, when the site is revisited the server will read the cookie to find the username, and then retrieve all the user’s information from the database without it having to be re-entered.

Is there are types of cookies?

Yes, There are quite a few types of cookies. We won’t go into too much detail about each of them, but these are two of the most common groups:

  • Session cookies are temporary files that are erased from your computer when you close your browser window.
  • Persistent cookies (also called permanent) stay on your computer until a fixed expiration date — for example, for a year.

So, after we explain all about what cookie is. Are cookies safe? Should I disable them from my browser?

Well, cookies can’t really “steal” your info — it just stores what you choose to let a website know about you. However, it’s quite common for some online advertisers to use cookies for tracking your browsing behavior and then show you some tailored ads which called “re-marketing”. Often it works through third-party cookies — i.e., set by a website different from what you’re viewing.

Considering the above mentioned, instead of disabling cookies entirely (which I wouldn’t recommend), consider blocking only third-party cookies.

Conclusion

  • Cookies are small text files stored in a web user’s browser directory or data folder.
  • Websites place cookies on visitors’ browsers to retain login credentials, identify customers, and provide a customized shopping experience.
  • Some of the common scenarios for using cookies are: When you fill a form on a website, you don’t have to enter the same details again with the next visit, thanks to a cookie, which stores them on your computer. Also, When you shop online, cookies store info as you put items in the shopping cart, so that you can pay for them all at once. Or If you chose a specific language in which you want to view a website, a cookie can remember this preference for subsequent sessions.

Please ❤ and Share

Thanks for reading this! Hopefully, these few points make the cookies explanation less confusing experience. If not, I’m happy to clear up any questions (or correct any errors you find in here).

Top comments (2)

Collapse
 
erilaysmith profile image
Erika Smith

this distinction of essential v. non-essential is so important! we delve into retargeted ads that you mentioned here - would be great to hear your thoughts

medium.com/metomic-incognito/what-...

Collapse
 
moopet profile image
Ben Sinclair • Edited

Actually, we deal with browser cookies (sometimes without knowing it) way more often than we have real cookies with our morning coffee

You underestimate my morning coffeetimes