simple-session

Cookie-based session management for the Simple web framework http://simple.cx

Version on this page:0.10.1.1
LTS Haskell 8.15:0.10.1.1
Stackage Nightly 2017-05-27:0.10.1.1
Latest on Hackage:0.10.1.1
LGPL-3 licensed by Amit Aryeh Levy
Maintained by amit@amitlevy.com

Module documentation for 0.10.1.1

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

comments powered byDisqus