如果我的cookie設置爲今天晚上7點過期,並且我在晚上6點30分開始會話,那麼在該會話期間但在晚上7點之後發出的請求將包含cookie,因爲會話結束或瀏覽器已將其刪除時會將其刪除?在會話期間Cookie是否過期?
0
A
回答
2
是的,cookies可以在會話期間過期並且經常這樣做。無論是在會話中,還是不在會話中,Cookies都會在到期時過期。如果服務器希望Cookie持續進行會話,它應該將Cookie重置爲會話Cookie,或者將來設置更長的到期時間。
瀏覽器不應該發送任何已過期到服務器的cookie。
最大年齡=值
可選:這是在RFC 2965(2000年10月),其中規定處理。的最大年齡屬性的值是Δ-秒,
cookie的以秒爲單位的壽命,十進制非負
整數。爲了正確地處理高速緩存的cookie,客戶端應根據年齡計算
計算cookie的年齡
在HTTP/1.1規範[RFC2616] 規則。 當年齡比Δ-秒秒
越大,客戶端應該丟棄
的cookie。值爲零表示cookie應該被丟棄
立即。
[強調]
,並說:
餅乾已經過期應該被拋棄,因此不 轉發到源服務器。
[強調]
本RFC通過2011年4月在該點是在適當位置從2000年10月,RFC 2965(2000年10月)中的溶液通過RFC 6265代替(2011年4月)。 RFC 6265改變了將過期的cookies從「應該」移除到「必須」的要求。RFC 6265說:
4. Server Requirements
...
4.1.2.1. The Expires Attribute
The Expires attribute indicates the maximum lifetime of the cookie,
represented as the date and time at which the cookie expires. The
user agent is not required to retain the cookie until the specified
date has passed. In fact, user agents often evict cookies due to
memory pressure or privacy concerns.
4.1.2.2. The Max-Age Attribute
The Max-Age attribute indicates the maximum lifetime of the cookie,
represented as the number of seconds until the cookie expires. The
user agent is not required to retain the cookie for the specified
duration. In fact, user agents often evict cookies due to memory
pressure or privacy concerns.
NOTE: Some existing user agents do not support the Max-Age
attribute. User agents that do not support the Max-Age attribute
ignore the attribute.
If a cookie has both the Max-Age and the Expires attribute, the Max-
Age attribute has precedence and controls the expiration date of the
cookie. If a cookie has neither the Max-Age nor the Expires
attribute, the user agent will retain the cookie until "the current
session is over" (as defined by the user agent).
...
5. User Agent Requirements
...
5.2.1. The Expires Attribute
If the attribute-name case-insensitively matches the string
"Expires", the user agent MUST process the cookie-av as follows.
Let the expiry-time be the result of parsing the attribute-value as
cookie-date (see Section 5.1.1).
If the attribute-value failed to parse as a cookie date, ignore the
cookie-av.
If the expiry-time is later than the last date the user agent can
represent, the user agent MAY replace the expiry-time with the last
representable date.
If the expiry-time is earlier than the earliest date the user agent
can represent, the user agent MAY replace the expiry-time with the
earliest representable date.
Append an attribute to the cookie-attribute-list with an attribute-
name of Expires and an attribute-value of expiry-time.
5.2.2. The Max-Age Attribute
If the attribute-name case-insensitively matches the string "Max-
Age", the user agent MUST process the cookie-av as follows.
If the first character of the attribute-value is not a DIGIT or a "-"
character, ignore the cookie-av.
If the remainder of attribute-value contains a non-DIGIT character,
ignore the cookie-av.
Let delta-seconds be the attribute-value converted to an integer.
If delta-seconds is less than or equal to zero (0), let expiry-time
be the earliest representable date and time. Otherwise, let the
expiry-time be the current date and time plus delta-seconds seconds.
Append an attribute to the cookie-attribute-list with an attribute-
name of Max-Age and an attribute-value of expiry-time.
...
5.3. Storage Model
...
A cookie is "expired" if the cookie has an expiry date in the past.
The user agent MUST evict all expired cookies from the cookie store
if, at any time, an expired cookie exists in the cookie store.
At any time, the user agent MAY "remove excess cookies" from the
cookie store if the number of cookies sharing a domain field exceeds
some implementation-defined upper bound (such as 50 cookies).
At any time, the user agent MAY "remove excess cookies" from the
cookie store if the cookie store exceeds some predetermined upper
bound (such as 3000 cookies).
When the user agent removes excess cookies from the cookie store, the
user agent MUST evict cookies in the following priority order:
1. Expired cookies.
2. Cookies that share a domain field with more than a predetermined
number of other cookies.
3. All cookies.
If two cookies have the same removal priority, the user agent MUST
evict the cookie with the earliest last-access date first.
When "the current session is over" (as defined by the user agent),
the user agent MUST remove from the cookie store all cookies with the
persistent-flag set to false.
相關問題
- 1. 會話cookie是否在午夜過期?
- 2. 會話Cookie不會在Android中過期
- 3. Cookie過期僅適用於會話Cookie
- 4. .ASPXAUTH cookie過期在會話結束
- 5. PHP會話在使用期間過期
- 6. 瀏覽器關閉時會話cookie是否過期?
- 7. 會話過期,我的cookie也會過期
- 8. 在會話過期之前cookie可以過期嗎?
- 9. 自動過期會話並檢測會話是否在Codeigniter中過期
- 10. ASP.NET會話過期時間
- 11. HTTPOnly將cookie過期設置爲會話
- 12. CURL - Cookie未啓用/會話過期
- 13. Codeigniter中的會話Cookie過期
- 14. 使用IdentityServer3滑動過期會話cookie
- 15. 當會話Cookie使用cURL過期時
- 16. cookie過期或會話超時太快
- 17. 春季會話Cookie永不過期
- 18. laravel 5.1檢查會話是否過期
- 19. 檢查快速會話是否過期
- 20. 會話變量是否在不同的時間量後過期?
- 21. Cookie過期日期正在採用magento中的會話值
- 22. Cookie過期時間
- 23. 到期asp.net會話cookie
- 24. 檢查cookie是否在iPhone中過期
- 25. 在SessionStore中設置Node.js快速會話過期時間,而不是在Cookie中
- 26. Cookie值在Cookie過期之前過期
- 27. 會話cookie在設置後會在下一頁上過期嗎?
- 28. Cookie到期與服務器的會話到期時間有關?
- 29. 使用activerecord會話存儲的cookie過期時間
- 30. 我如何檢查Magento中的會話或Cookie過期時間
謝謝,非常詳細! – 2014-10-06 13:32:14