零点课堂 | What Are Cookies?（1）
It's hard to navigate the Internet these days without coming across a box asking you to Accept All Cookies before you proceed. Perhaps you’re one of those mythical beasts that actually bothers to read the cookie and privacy policies. In reality, though, most of us will just accept them without a second thought.
You might have heard that Cookies have something to do with improving your experience. They're often used to tailor site content to your own preferences – like storing items in your online shopping cart between sessions, for example.
In this article, we'll take a deep dive into cookies: the good, the bad, and the ugly.
What is a cookie?
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.
Types of cookies
Suppose that you visit everybody's favorite honey-badger-themed website, ilovehoneybadgers.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 mammal appreciation site and then close your browser, but when you come back, ilovehoneybadgers.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 ilovehoneybadgers.com domain).