package sihl

  1. Overview
  2. Docs
val find : ?cookie_key:string -> ?secret:string -> string -> Request.t -> string option

find ?cookie_key ?secret key request returns the value that is associated to the key in the current session of the request.

cookie_key is the name of the session cookie. By default, the value is _session.

secret is the secret used to sign the session cookie. By default, SIHL_SECRET is used.

get_all ?cookie_key ?secret request returns all values in the current session of the request.

cookie_key is the name of the session cookie. By default, the value is _session.

secret is the secret used to sign the session cookie. By default, SIHL_SECRET is used.

val get_all : ?cookie_key:string -> ?secret:string -> Request.t -> (string * string) list option
val set : ?cookie_key:string -> ?secret:string -> (string * string) list -> Response.t -> Response.t

set ?cookie_key ?secret data response returns a response that has data associated to the current session by setting the session cookie of the response. set replaces the current session.

cookie_key is the name of the session cookie. By default, the value is _session. If there is a session cookie already present with that name it gets replaced.

secret is the secret used to sign the session cookie. By default, SIHL_SECRET is used.

val set_value : ?cookie_key:string -> ?secret:string -> key:string -> string -> Request.t -> Response.t -> Response.t

set_value ?cookie_key ?secret key value request response transfers the session from request to a new response, updates the session where key is associated with value and returns a new response. If key has no binding in the session, a new binding is added. Other bindings are not affected.

cookie_key is the name of the session cookie. By default, the value is _session.

If no session with name cookie_key is found, an error message is returned.

secret is the secret used to sign the session cookie. By default, SIHL_SECRET is used.

val update_or_set_value : ?cookie_key:string -> ?secret:string -> key:string -> (string option -> string option) -> Request.t -> Response.t -> Response.t

update_or_set_value ?cookie_key ?secret key f request response transfers the session from request to a new response, updates the session where a value associated with key is added, removed or updated by passing in the value to f. If key has no binding in the session, the input to f is None. If a binding a is found for key, the input to f is Some a. If f returns None, the binding for key is removed. Other bindings are not affected.

cookie_key is the name of the session cookie. By default, the value is _session. If there is no session cookie present, a new one is set and f None is added to the session.

secret is the secret used to sign the session cookie. By default, SIHL_SECRET is used.

OCaml

Innovation. Community. Security.