Not the Edible Kind
The web has a curious quirk: by default, a website forgets you the instant you leave. Each time you load a page, the site treats you as a brand new stranger. Yet in practice, sites clearly remember things. They keep you logged in, hold the items in your shopping basket, and recall your language. The small trick that makes this possible is the cookie.
A Small Note Left Behind
A cookie is just a small piece of text that a website asks your browser to save on your device. Think of it as a little note the site hands you, saying something like "this visitor is logged in" or "this visitor prefers English." The next time you visit, your browser quietly hands the note back, and the site reads it to remember who you are. The cookie itself is plain data, not a program, so it cannot run or do anything on its own.
What Cookies Are Used For
Cookies do a lot of helpful work. They keep you signed in so you do not have to type your password on every page. They remember your settings and the contents of a shopping basket. They can also record that you have already seen a particular notice, so it does not pop up again. Many of the everyday conveniences of the web rely on this simple ability to remember you from one page to the next.
The Privacy Side
Cookies also have a more debated use. A first-party cookie is set by the site you are actually visiting. A third-party cookie comes from another company, often an advertiser, whose content is embedded in many different sites. By recognizing the same cookie across all those sites, that company can build a picture of where you go online, which is how some targeted advertising works. This is why browsers now offer controls to block or clear cookies, and why websites ask for your consent before setting certain ones.
Source
This article was written using information from Wikipedia.