We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
To add cookie support to your Ring handler, you'll need to wrap it in the wrap-cookies middleware:
wrap-cookies
(use 'ring.middleware.cookies) (def app (wrap-cookies your-handler))
This adds the :cookies key to the request map, which will contain a map of cookies looking something like this:
:cookies
{"session_id" {:value "session-id-hash"}}
To set a cookie, you add a :cookies key to the response map:
{:status 200 :headers {} :cookies {"session_id" {:value "session-id-hash"}} :body "Setting a cookie."}
As well as setting the value of the cookie, you can also set additional attributes:
:domain
:path
:secure
:http-only
:max-age
:expires
:same-site
:strict
:lax
:none
So if you wanted to have a secure cookie that expires in one hour, you'd use:
{"secret" {:value "foobar", :secure true, :max-age 3600}}
Next Page - Sessions