Cookie-based session management for the Simple web framework

Version on this page:
LTS Haskell 14.27:
Stackage Nightly 2019-09-21:
Latest on Hackage:1.0.0

See all snapshots simple-session appears in

LGPL-3.0-only licensed by Amit Aryeh Levy
Maintained by [email protected]

Module documentation for

This version can be pinned in stack with:[email protected]:420fb24c61a5dd0aaedce2cedaf8ca63d805687eb55e22d443b3fb5207de9041,1638

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]


Version (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