package sihl
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=574c73c97ea0bc57144853b28df6125855a040ef0378f3bf180b4331dde93f9d
sha512=92c474ed3b6609395799f77259fc424af37dcad53095773ca2f2cdd4757a1607a5b53b6594cd7b6ddabeb40ebba67bb9544ff0f31dc228c87cfe015afa520aaa
doc/sihl.http/Http/Cookie/index.html
Module Http.Cookie
Source
Cookie management for both requests and responses.
A single header represented as a key-value pair.
expires
describes when a cookie will expire.
`Session
- nothing will be set`Max_age
- Max-Age will be set with the number`Date
- Expires will be set with a date
The value of a cookie is a tuple of (name, value)
Constructors
make
val make :
?expires:expires ->
?scope:Uri.t ->
?same_site:same_site ->
?secure:bool ->
?http_only:bool ->
?sign_with:Signer.t ->
value ->
t
make cookie
creates a cookie with the key-value pair cookie
It will default to the following values:
Note that if no value is given for scope
, the browsers might use a default value. For instance, if the cookie is set from the response of http://example.com/users/login
and does not specify a scope, some browsers will use /users
as a scope. If you want the cookie to be valid for every endpoint of your application, you need to use "/"
as the scope of your cookie.
of_set_cookie_header
of_set_cookie_header ?signed_with ?origin header
creates a cookie from a Set-Cookie
header header
.
If the header is not a valid Set-Cookie
header, None
is returned.
to_set_cookie_header
Encoders
to_set_cookie_header
to_set_cookie_header t
creates an HTTP header for the cookie t
.
to_cookie_header
to_cookie_header ?now ?elapsed ?scope cookies
creates an HTTP header for the list of cookies cookies
.
Decoders
cookie_of_header
cookie_of_header ?signed_with key header
returns the value of a the cookie with the key key
in the header header
.
If the cookie with the key key
does not exist, or if the header is not a valid Cookie
header, None
will be returned.
cookies_of_header
cookies_of_header ?signed_with header
returns the list of cookie values in the header header
.
If the header is not a valid Cookie
header, an empty list is returned.
cookie_of_headers
cookie_of_headers ?signed_with key headers
returns the value of a the cookie with the key key
in the headers headers
.
If the cookie with the key key
does not exist, or if no header is not a valid Cookie
header, None
will be returned.
cookies_of_headers
cookies_of_headers ?signed_with headers
returns the list of cookie values in the headers headers
.
If no header is not a valid Cookie
header, an empty list is returned.
Utilities
sexp_of_t
sexp_of_t t
converts the cookie t
to an s-expression.
pp
pp
formats the cookie t
as an s-expression.