simple-session

Cookie-based session management for the Simple web framework

http://simple.cx

LTS Haskell 22.13:2.0.0
Stackage Nightly 2024-03-14:2.0.0
Latest on Hackage:2.0.0

See all snapshots simple-session appears in

LGPL-3.0-only licensed by Amit Aryeh Levy
Maintained by [email protected]
This version can be pinned in stack with:simple-session-2.0.0@sha256:e51076aa8ec775a7e75a7a59c0f0eb1d29db7a365222e543b4dcdacb45c0485d,1636

Module documentation for 2.0.0

Adds cookie-based session management to simple Controllers. To add to an application, declare the Controller setting's type an instance of HasSession, and wrap routes with withSession. For example:

data AppSettings = ...

instance HasSession AppSettings where
  ...
controllerApp settings $ withSessions $ do
  routeName \"posts\" $ ...

Then, in your controllers you can seemlessly get and set keys from the session:

get "/profile" $ do
  muserId <- sessionLookup "current_user_id"
  case muserIf of
    Nothing -> respond $ redirectTo "/login"
    Just userId -> [handle request]

Changes

Version 0.10.1.0 (2015-11-18)

  • Default to using httponly cookie option

  • Default to using secure cookie option for requests over HTTPS

  • Allow customization of cookie options using the sessionBaseCookie method