wisp_kv_sessions

Functions

pub fn delete(
  config: Config,
  req: Request(Connection),
  key: String,
) -> Result(Session, SessionError)

Delete key from session

pub fn delete_session(
  config: Config,
  req: Request(Connection),
) -> Result(Nil, SessionError)

Remove session Usage:

sessions.delete(store, req)
pub fn get(
  config: Config,
  req: Request(Connection),
  key: String,
  decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> Result(Option(a), SessionError)

Get data from session by key

pub fn get_session(
  config: Config,
  req: Request(Connection),
) -> Result(Session, SessionError)

Try to get the session from the store. If it does not exist create a new one.

pub fn middleware(
  config: Config,
  req: Request(Connection),
  handle_request: fn(Request(Connection)) -> Response(Body),
) -> Response(Body)

Create a session if no session exists to make sure there always is a session_id to store data towards Usage:

use <- sessions.middleware(config, req)
pub fn replace_session(
  config: Config,
  res: Response(Body),
  req: Request(Connection),
  new_session: Session,
) -> Result(Response(Body), SessionError)

Replace the session with a new one Usage:

wisp.ok() |> replace_session(session_config, req)
pub fn set(
  config: Config,
  req: Request(Connection),
  key: String,
  data: a,
  encoder: fn(a) -> String,
) -> Result(a, SessionError)

Set data in session by key

Search Document