1. Current Location: Home >  Router Encyclopedia >  The website relies on cookies to remember login, and if you catch a receipt, it can sit idle for up to a year

The website relies on cookies to remember login, and if you catch a receipt, it can sit idle for up to a year

What is a cookie illustration: Website issues a storage tag, browser invoice delivery, set-cookie segment breakdown and cache clearing comparison table

Last month, I went to my friend's home to help him adjust the router, and casually logged into his computer to download the firmware from a cloud drive. This week, he called me over again. When I opened the browser, the cloud drive was still logged in, and the file list was right there. I didn't let him save my password, nor did he click to log out. How could it recognize me? When I came back, I broke it down and saw the answer was just a short string of text, technically called a cookie. Today's article explains it clearly, and also addresses the old question of "Will clearing cache remove passwords?"

To clarify: a cookie is a storage token that a website sends to you

We have to start with the inherent flaws of HTTP as a "language." Previously, I < a href="https://www.shunot.com/en/lybk/1117.html" > packet capture explaining the difference between http and https, mentioning that http has no memory. This time you request a webpage, the server forgets who you are after the server finishes the service, and the next moment you refresh, it sees a brand new face in its eyes. This is called statelessness.

But places like cloud drives, email, and blog backend need to "remember you." The engineer's solution is especially rustic: When you first arrive, the server casually slips you a receipt when it responds, and it says "Number 27315." Your browser stores the tickets in a small notebook. Next time you visit this site, the browser will pull up the ticket and automatically insert it into the request and hand it over. Server pair: Oh, 27315, old acquaintance, come in.

Just like that, back and forth. A cookie is a receipt issued by the website and stored by the browser on its behalf. You feel like "the website remembers me," but it's actually the browser handing you the ticket. Change computers or browsers, the notebook is empty, no tickets to hand in, and the website will pretend it doesn't recognize you—that's why if you log in on your computer at home, you have to log in again on your phone, and each side has its own notebook.

I grabbed a bag, and this receipt looks like this

Just talking about metaphors isn't enough, so I took Curl and got a real answer. Visiting Baidu's homepage, the server response shows a line:

Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/

Dissecting section by section. BDORZ is the name of the ticket, 27315 is the ticket number, and these two are connected by equal signs, forming the main text on the bill. domain=.baidu.com They say the ticket only works on Baidu's domain; other sites don't recognize it, and browsers won't hand Baidu tickets to Taobao. path=/ is the jurisdiction range, and the slash represents the site-wide usage. The most interesting is max-age = 86400 — this is the validity period, measured in seconds, 86400 divided by 24 divided by 3600, exactly one day.

To verify "next time it will be automatically carried on," I saved the ticket received on the first visit into a file, then immediately followed the original address on the second visit and grabbed the request header. Sure enough, a line of Cookie: BDORZ=27315 appeared. I didn't do anything; the browser (here I did curl for it) handed over the ticket itself. The entire process is exactly the same as storing a bag in a mall: store the bag and give it a token, pick up the bag and hand it over. Once the card is in hand, the bag is yours.

There are

two types of tickets: those that expire when you close the browser and those that can sit for a year

Even cookies have two levels of lifespan. I grabbed another comparison—when I visited GitHub, the ticket it sent out had a token called _gh_sess, followed by path=/; HttpOnly; Secure; SameSite=Lax, but no expires or max-age. Tickets without expiration date are recorded by the browser as a "session cookie." Once the window closes, the ticket is voided along with the session. Most of these tickets are installed in temporary login mode, so on some websites, if you close your browser and open them again, you have to log in again. It's not that the ticket is broken, but that the ticket is designed to be one-time only.

Another level is persistent cookies with explicit expiration dates. GitHub also issued a _octo ticket, which caught the packet in October 2026. Its expiration page reads Mon, 04 Oct 2027—a whole year. These tickets are stored on the plate; even when the browser is closed and restarted, the computer reboots, they remain and are destroyed on their own. Next to the website login box, the "Remember Me" checkbox. Whether or not you check the box usually depends on whether your invoice has an expiration date: if you check 'issue a lasting invoice,' you won't issue a session ticket.

The most interesting thing is that among those GitHub tickets, there's one named logged_in, with a value of no. In other words, the question of "whether you logged in or not" is just a single word on a cookie on their platform. After logging in, the server updates it to yes, and the browser stores it for a year. Next time you visit, the browser will send this yes icon, and the top right corner of the page will show your avatar. The so-called login status is essentially just that simple.

Which layer is there for clearing cache and login login? Don't mix the three layers together

This is the most frequently asked question and also the easiest to get wrong. First, place three layers of items on the table, each sitting in different drawers in the browser

What happens what ? . You checked the saved account ,
if you clearyou stored
Cookies, login receipts for each website, login to all sites, log out and log in again
password in the browser password databaseAutofill is gone, password itself is still (if you remember),
web cacheimages, scripts, and other files slow down for one or two rounds, I explained in detail in the article about caching

So the answer is split into two halves: in the browser, click "Clear browsing data," and the pop-up checkbox will have three separate boxes for cookies, passwords, and caches. If you only check the cache, both the password and login mode are fine; If you check cookies, the login state disappears but the password database remains, and the account password can still be automatically filled in the next time you log in—provided you saved it before. I < the article about changing management passwords > a href=""https://www.shunot.com/192-168-1-1/917.html" mentioned the old browser stuffing, which refers to the password library drawer, which is different from cookies.

By the way

, Windows also has a fourth drawer called the credential manager, which stores system-level accounts like LAN sharing and mapping disks. My cousin even reported 'System Error 1219' on his NAS at the time. The root of the problem is there, and it doesn't even connect with browser cookies. For details, see NAS can't connect to that credential cache check.

Once the layers are clarified, "logout login" becomes easier to understand. Clicking that button, the backend actually does two things: first, the server invalidates your ticket number in its own registry; second, it has the browser tear up the tickets in your hand. Only when both sides are cleared together can it be considered a clean exit.

But many people simply close the webpage on shared computers. This is where the problem arises: the ticket is still lying in the browser, especially the persistent cookies, which are still registered the next time you open them. The cloud drive on my small computer is exactly like this. What's even more troublesome is that even if you only clear the cookies on the browser's side, the server's registry remains untouched—the ticket number is still in the register, but you just don't have the ticket anymore. It may sound trivial, but if you think about it the other way around, it becomes clear: if the ticket is copied elsewhere (for example, a middleman copying it, or a malicious script on your computer flipping through your notebook), the ticket holder is the legitimate you.

So the iron rule of sharing a computer is to use the legitimate "Log Out" button, not just close the webpage; Before lending your computer to someone else, make sure to log in completely. I < a href="https://www.shunot.com/en/192-168-1-1/1038.html"> wrote about checking for routers being hacked, and it reminded me to change passwords after getting scammed. Actually, I was still half sentence short: after changing the password, I also cleared my browser cookies to invalidate all old tickets, so the door was closed.

For HttpOnly and SameSite, the two lines of small text on the back of the ticket are for life-saving

protection

Looking back at the three suffixes on the GitHub _gh_sess ticket, each has its own details.

HttpOnly means this ticket only allows HTTP layer to pass back and forth; JavaScript on the webpage cannot be touched. Why is it important? Because there's a type of attack called XSS, which works by inserting a bad script into the web you browse. Once the script runs, it digs through your browser's small notebook and copies your login password and sends it to the attacker. If the ticket says HttpOnly and the script can't be accessed, this trick is mostly useless. Baidu's BDORZ doesn't have this suffix, because it's a statistical ticket, so losing it doesn't matter; Tickets registered in status are generally printed on them.

Secure means "this ticket only goes through the crypto channel." Tickets with this suffix, HTTP plaintext channels, are never submitted; only HTTPS are accepted. Thinking about it, that makes sense. http is a plain naked route. If you log in and take this route, it's like holding your house key and walking at night.

SameSite=Lax is in charge of a different matter: can other websites deliver tickets for you? The normal process is: "You operate on the Baidu page yourself, and the browser hands over Baidu's ticket to Baidu." But embedded images or links on webpages can also trigger requests to third-party websites, allowing attackers to create phishing pages to lure your browser into using your ticket on a certain site to do bad things. This is called CSRF. SameSite restricts that only requests made from this site page allow ticket inclusion; phishing sites want to borrow your ticket, but there's no way. These three phrases are usually used during website development without you having to do them yourself, but once you understand them and encounter security news, at least you know what it's saying.

Conclusion: One sheet clearly states who manages what

to do. . The . password . it. of
What do you want to do? Move whichever layer you need
The site is still logged in but I don't want cookies. Click 'Inside the site' to log out, it's the cleanest
webpage displays old content, cache, and press Ctrl+ F5 forced flashing, if it doesn't work, clear cache
Changing computers or browsers requires re-login, which is normal. Small notebooks don't cross devices; logging in again means
forgetting the password and cannot automatically fill in thedatabaseCheck the password saved in the browser or retrieve
Suspect the account has been tampered with Complete setpassword changes + cookie clearing, two approaches at once

In the end, cookies are just tools—websites use them to identify people, and you can enter your password fewer times. The criticisms it carries—ad tracking, privacy leaks—are mostly due to its actions; the votes themselves are not inherently sinful. In your browser settings, you can see the name and expiration date of each ticket. If you have a chance, just glance at your frequently used stations and see which tickets last a year, and which expires when you close the browser. It's quite interesting. As for the cloud drive on my small computer, I logged out and logged in before leaving, and I also turned off the browser save password—that was another account in the password drawer.

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《The website relies on cookies to remember login, and if you catch a receipt, it can sit idle for up to a year》
Article URL: https://www.shunot.com/en/lybk/1123.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow