I'm sending the following response in clojure ring:
(res/set-cookie
(res/redirect (env :some-url))
"some-id"
(->
req
foo-ns/bar
:id
)
{:max-age (* 30 24 60 60 1000) :path "/"})
And on printing this response I get:
{:status 302, :headers {"Location" "http://localhost:5000"}, :body "", :cookies {"some-id" {:value "1341313515135490454", :max-age 2592000000, :path "/"}}}
But on the client side, the cookie isn't set, which I can see in the console. What am I doing wrong?
It looks like you're using
ring.response/set-cookie
to set the cookie. That will set the cookie attributes under:cookies
in your response map. Before returning the response to the browser, you need to encode those cookies into aSet-Cookie
header that the browser can understand. To do this, add thering.middleware.cookies/wrap-cookies
middleware to your middleware stack.You should expect your response to look something like: