有两种类型的 cookie:
1) Server side cookie
2) Client (HTTP) side cookie
当您从浏览器中清除 cookie 时,它只会清除客户端 cookie(您机器上的 cookie)。是的,所有 cookie 都设置了过期时间。
一些信息给你:
客户端 cookie
Cookie 是网站用来在浏览器上存储状态信息的键/值对。假设您有一个网站(example.com),当浏览器请求一个网页时,该网站可以发送 cookie 以在浏览器上存储信息。
浏览器请求示例:
GET /index.html HTTP/1.1
主机:www.example.com
来自服务器的示例答案:
HTTP/1.1 200 OK
Content-type: text/html
Set-Cookie: foo=10
Set-Cookie: bar=20; Expires=Fri, 30 Sep 2011 11:48:00 GMT
... rest of the response
这里有两个 cookie foo=10 和 bar=20 存储在浏览器上。第二个将于 9 月 30 日到期。在每个后续请求中,浏览器都会将 cookie 发送回服务器。
GET /spec.html HTTP/1.1
Host: www.example.com
Cookie: foo=10; bar=20
Accept: */*
SESSIONS: Server side cookies
服务器端 cookie 称为“会话”。在这种情况下,网站在浏览器上存储一个包含唯一会话标识符的 cookie。状态信息(上面的 foo=10 和 bar=20)存储在服务器上,会话标识符用于将请求与存储在服务器上的数据进行匹配。
点击此处了解更多详情:
What is the difference between server side cookie and client side cookie?
When session cookies are cleared, they are removed from the client (your machine). Now, the server can't identify you since it doesn't know the session id which was in the cookie you cleared recently, and so it looks like your session is cleared.
部分功劳归于回答该问题的人!!