dagolden / HTTP-CookieJar

A minimalist HTTP user agent cookie jar
2 stars 7 forks source link

Meaning of creation_time and last_access_time #12

Closed jjatria closed 2 years ago

jjatria commented 2 years ago

The documentation for cookies_for has this to say about these fields in the cookie hash references:

creation_time -- epoch seconds since the cookie was first stored last_access_time -- epoch seconds since the cookie was last stored

But it seems to me this is not entirely accurate: it's not so much the "seconds since X", but the UNIX timestamp at which X took place. If I'm correct, then maybe a more accurate phrasing would be something like:

the moment the cookie was ???, as a UNIX timestamp

This made me think about the meaning of last_access_time. The docs say that this is when the cookie was "last stored". But reading through section 5,.4 of RFC 6265, where it describes the algorithm that must be followed to set the Cookie header, it states that the step right before actually generating the header is:

  1. Update the last-access-time of each cookie in the cookie-list to the current date and time.

which suggests the last_access_time should be the moment the cookie was last read (which makes sense based on the key). Or am I reading things wrong?

If I'm not mistaken, should HTTP::CookieJar be changed so that last_access_time is updated every time a cookie is "matched" by cookies_for?

i understand that this is a little academic, since last_access_time is not really used for anything. But the RFC seems to be pretty specific about this, and HTTP::CookieJar aims to be conformant with it.

xdg commented 2 years ago

Thanks!