ring

robert-stuttaford 2022-12-19T16:42:53.246199Z

what could cause ring cookies to produce a new session cookie-store encrypted value on each request? when i watch the cookie in Chrome, the value changes every refresh. the actual behaviour is fine - my session is working and my app does what i want. just seems odd that it keeps making a new value each time

Hukka 2022-12-19T18:38:35.322639Z

https://github.com/ring-clojure/ring/blob/1.9.0/ring-core/src/ring/middleware/session.clj#L61 hm, the logic is there. But hard to say what could be changing the :session-cookie-attrs, or put the :recreate key in the response

Hukka 2022-12-19T18:39:07.936689Z

Could something be setting the session age, for example, all the time?

Hukka 2022-12-19T18:40:14.111499Z

I don't think core ring has anything that sets those, so it should be in other parts

Hukka 2022-12-19T18:41:22.410819Z

You could start by printing the relevant parts of the response right before the session middleware checks it, so you know which path it goes down to

Hukka 2022-12-19T18:41:47.356109Z

Then move your debug middleware up layer by layer, so you catch where it happens

Hukka 2022-12-19T18:42:01.487759Z

(or if the stack is deep, binary search 😉

robert-stuttaford 2022-12-19T19:21:17.179269Z

thanks Hukka!

dharrigan 2022-12-20T13:06:18.787649Z

Are you using reitit?

robert-stuttaford 2022-12-20T13:26:19.292379Z

yep

robert-stuttaford 2022-12-20T13:27:22.797269Z

we also have a lib-noir server (from years ago) that we're still using and its cookie value is stable from page to page, so i lost half a day trying to figure out why, until i recognised that the session was still working as i wanted it to

dharrigan 2022-12-20T13:35:29.369839Z

you may be hitting this bug? https://github.com/metosin/reitit/issues/205

dharrigan 2022-12-20T13:36:21.893719Z

What I had to do was to have a global store, and not put the wrap-session in the route middleware.

robert-stuttaford 2022-12-20T14:14:58.772229Z

oh interesting, going to give that a close read

robert-stuttaford 2022-12-20T14:15:23.008779Z

also i should read Issue logs 😅

robert-stuttaford 2022-12-20T15:41:04.392019Z

thanks for this, i don't have this specific issue; i implemented my own interceptor instead of using their middleware

dharrigan 2022-12-20T18:14:44.353349Z

np, glad you sorted it out 🙂