A cookie is a small file your computer stores on behalf of a website. There's a disappointing lack of sugar in them, unfortunately. The name, attributed to programmer Lou Montulli, is based on the name of another computing construct called a magic cookie.
But why do computers store that file? Well, there are a few different reasons. Broadly speaking, cookies help a web server to remember you. You'll do somETHing on the website (it could be anything from switching to dark mode to logging in), and your computer makes a note of this. Then, the next time you visit, it hands the information back to the website.
First-party cookies
Suppose that you visit website BitKan.com, It comes with plenty of customization options (e.g., changing your font to Comic Sans or switching the background color). A cookie that notes these preferences is saved to your computer. You navigate away to another site and then close your browser, but when you come back, BitKan.com reloads your tailored settings based on the cookie.
This is a persistent cookie. It remains even after you close the browser (unlike a session cookie, which is destroyed upon quitting). It's also a first-party cookie because it was created by the website you visited (in this case, the BitKan.com domain).
Third-party cookies
You might have guessed that a third-party cookie is one that wasn't created by the host domain. Suppose now that both BitKan.com and another website that you visited serve ads to their users. Those ads come from the same provider, whose code is injected into the webpage of both domains.
When you visit either site, the provider creates a third-party cookie for tracking purposes. Then, as you move around the web to other sites with their code, they'll recognize you and serve up the same ads. Essentially, they track your browsing habits to build out a profile used for targeting.
Unsurprisingly, third-party cookies are also known as tracking cookies.
What are cookies made of?
Not all cookies are created equal. As we've seen from the two examples in the previous section, they're a versatile data type. Let's now look at a real-life example: if you've signed into Ask Academy, your browser will show you a cookie for the site. This is what allows you to post questions and answers without constantly needing to log in again.
On Google Chrome, access your cookies by navigating to Settings > Privacy and security > Cookies and other site data. On Firefox, manage cookies under Preferences > Privacy & Security > Cookies and Site Data (note that you should use the Storage Inspector to view their actual contents).
Cookies typically have this key-value pair system. Note that many sites nowadays will provide a user ID. Once an individual visits, the server checks its database for any information it has on them and tailors the user experience accordingly.
If you fire up the prompt to clear your browsing history, you generally get the option to clear cookies, too. When you do this, you don't cause any major damage to site data. You'll notice, however, that you'll need to reenter any login information when you return to the sites that provided you with the cookies.


















