Fork me on GitHub
#ring
<
2020-03-29
>
Spaceman17:03:24

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" ""}, :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?

seancorfield18:03:47

@pshar10 I'm pretty sure you cannot reliably set cookies on a redirect response. It's not supported by all browsers.

Spaceman18:03:23

The point is that the req is coming from google oauth, and after the request arrives I want to redirect the user to some route, while setting a cookie that they are logged in. So how can I do both if one cannot set cookies in a redirect?