What is a cookie?
Many of us have heard about cookies, local storage, and session storage but do you know what they are exactly? Let me explain them to you in the simplest of ways…
I am sure you have encountered numerous such websites that flash that information, even before you browse that particular site.
So what are they? They are called cookies.
Cookies are just small text files that are placed on your (user’s) device. They hold a very small amount of data with a max capacity of just 4KB. They are used for various purposes such as storing pages visited on a site or a user’s login information so that they do not have to re-enter their credentials every time.
Cookies play a very important role in customizing the user experience based on the user’s browsing history for that site.
A Cookie can be set from an HTTP header. Usually, the server that you’re trying to reach, if it has cookies, will send an HTTP header like this:
When your browser receives this header, it saves the this_is_a_cookie Cookie.
Remember! Cookies are associated with websites. You can only see the cookies of the website you are browsing.
To see the cookies you have, if you have Firefox, from your devtools, go to storage > Cookies; if you have Chrome, from your devtools, go to Application > storage > Cookies.
document.cookie = “this_is_a_cookie=sample_cookie”;
For a long time, cookies were the main way to store information about users. This scenario changed after HTML5 came into existence and introduced LocalStorage as another data storage option. I will explain the difference between local storage and cookies in another video. You can ask any questions related to cookies in the comment section.
Looking for remote/contract Web/UI/Full stack opportunities in the US? Connect with the leading staffing experts of the industry today.
Founder and CEO of an IT company in India, I have more than 25 years experience of in dealing with people, processes, and codes. I started online training for my students when it was not in fashion and have trained more than 1000 students/working professionals personally which has helped them to secure awesome jobs or even start their own businesses.
I am also been an active corporate trainer for several years now and have been consulting with top Fortune 500/1000 companies to streamline their development projects efficiently. My goal is to share knowledge with a primary focus on advanced tools & techniques, projects, and standard programming practices to help my students understand the basics and fundamentals and make awesome technological implementations.