Middleware for parsing and generating cookies. Reuses standard implementation
with delayed :cookies in request.
Middleware for parsing and generating cookies. Reuses standard implementation with delayed `:cookies` in request.
(cookies-request-fn {:keys [decoder] :or {decoder codec/form-decode-str}})Parses the cookies in the request map, then assocs the resulting map to the
delayed :cookies key on the request.
Accepts the following options:
:decoder – a function to decode the cookie value.
Each cookie is represented as a map, with its value being held in the :value
key. A cookie may optionally contain a :path, :domain or :port
attribute.
Parses the cookies in the request map, then assocs the resulting map to the
delayed `:cookies` key on the request.
Accepts the following options:
- `:decoder` – a function to decode the cookie value.
+ Expects a function that takes a string and returns a string.
+ Defaults to URL-decoding.
Each cookie is represented as a map, with its value being held in the `:value`
key. A cookie may optionally contain a `:path`, `:domain` or `:port`
attribute.
(cookies-response-fn {:keys [encoder] :or {encoder codec/form-encode}})For responses with :cookies, adds Set-Cookie header and returns response
without :cookies.
Accepts the following options:
:encoder – a function to encode the cookie name and value.
To set cookies, add a map to the :cookies key on the response. The values of the cookie map can either be strings, or maps containing the following keys:
:value – the new value of the cookie:path – the subpath the cookie is valid for:domain – the domain the cookie is valid for:max-age – the maximum age in seconds of the cookie:expires – a date string at which the cookie will expire:secure – set to true if the cookie requires HTTPS, prevent HTTP access:http-only – set to true if the cookie is valid for HTTP and HTTPS only
(i.e. prevent JavaScript access):same-site – set to :strict or :lax to set SameSite attribute of the
cookieFor responses with `:cookies`, adds `Set-Cookie` header and returns response
without `:cookies`.
Accepts the following options:
- `:encoder` – a function to encode the cookie name and value.
+ Expects a function that takes a name/value map and returns a string.
+ Defaults to URL-encoding.
To set cookies, add a map to the :cookies key on the response. The values
of the cookie map can either be strings, or maps containing the following
keys:
- `:value` – the new value of the cookie
- `:path` – the subpath the cookie is valid for
- `:domain` – the domain the cookie is valid for
- `:max-age` – the maximum age in seconds of the cookie
- `:expires` – a date string at which the cookie will expire
- `:secure` – set to true if the cookie requires HTTPS, prevent HTTP access
- `:http-only` – set to true if the cookie is valid for HTTP and HTTPS only
(i.e. prevent JavaScript access)
- `:same-site` – set to `:strict` or `:lax` to set SameSite attribute of the
cookie
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |