Rails: cookie read date

How can I find out the date a cookie was set? In the rails api I cannot find this information, google also has no ...

+2


source to share


1 answer


You can not. This is how cookies work:

The client requests a document and receives in response:

  Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT

      

When a client requests a URL in the "/" path on this server, it sends:



  Cookie: CUSTOMER=WILE_E_COYOTE

      

The idea is that the browser controls whether it should send the cookie back to the server or not. The web server is not aware of the cookie expiration date.

Later edit : Wikipedia for more details on this:

Cookies expire, and therefore not sent by the browser to the server, under any of these conditions:

  • At the end of the user's session (i.e. when the browser is off) if the cookie is not persistent.
  • Expiration date is listed and passed
  • The cookie expiration date is changed (by server or script) to a date in the past
  • The browser deletes the cookie at the user's request

The third condition allows the server or script to explicitly delete the cookie. Please note that the browser does not send information about the server cookie life, so there is no way for the server to check if the cookie expires anytime soon.

+3


source