Fork me on GitHub
#ring
<
2022-09-14
>
OknoLombarda05:09:50

Hi, I have a problem setting a cookie with "expires" attribute

(assoc (response/ok)
       :cookies {"hehe" {:expires "2022-10-14T03:26:52.000Z"
                         :value "eheheeheh"}})
Using this code, the cookie gets set, but the "expires" attribute is just ignored. Why does this happen? How can I debug it? I use default ring middleware

hiredman05:09:15

Browser is likely ignoring the date because it is not the right format for cookies

hiredman05:09:26

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie has a section on expires with a link to a place that talks about how those dates are formatted

hiredman05:09:56

If joda time is available, ring also supports passing a joda datetime instead of a string, and you can see how it formats those https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/middleware/cookies.clj#L84

OknoLombarda05:09:07

yeah, ZonedDateTime worked. Thank you, I've spent a few hours trying different things, going through source code before asking (╯ ͡° ͜ʖ ͡°)╯︵ ┻━┻