How can i read cookie set date? In rails api I can not find this information, google a开发者_开发技巧lso doesn't have...
You can't. Here is how the cookies work:
Client requests a document, and receives in the response:
Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT
When client requests a URL in path "/" on this server, it sends:
Cookie: CUSTOMER=WILE_E_COYOTE
The ideea is that the browser manages wheter it should send back the cookie to the server or not. The web server is not informed about the expiration date of the cookie.
Later edit: Wikipedia is even more precise about this:
Cookies expire, and are therefore not sent by the browser to the server, under any of these conditions:
- At the end of the user session (i.e. when the browser is shut down) if the cookie is not persistent
- An expiration date has been specified, and has passed
- The expiration date of the cookie is changed (by the server or the script) to a date in the past
- The browser deletes the cookie by user request
The third condition allows a server or script to explicitly delete a cookie. Note that the browser doesn't send to the server information about cookie lifetime, so there is no way for the server to check if the cookie expires soon.
精彩评论