A Cookie is a small text file that is created by a website and stored on your browser. It contains a small set of information about you to identify you once you revisit the website from the web browser.
This way, a website can load the content based on your preferences and give you a personalized experience. Cookies are also often termed web cookies, browser cookies, etc.
Use Cases and Examples
Cookies are meant to hold the state of the browser session. For example, you visit an e-commerce website, put some items in the cart, and then close the website or switch to another page. Once you revisit the website, you will still be able to see the same items in the cart. Similarly, cookies also facilitate auto-filling the user name, password, and other details.
Ad serving companies rely heavily on cookies to store your search information and then present you with relevant ads. For example, you searched about something on Amazon and now you will be seeing relevant ads on Facebook.
Cookies are accessible by browser, the website you are on, or the third party, all meant to provide a more personalized experience to you and improve the website's usability. There are other ways to store data within the browser including localstorage, session storage, web SQL etc.
Here is another article for you 😊 "Letter to an aspiring developer"