snap-0.12.0: Top-level package for the Snap Web Framework

Safe Haskell | None

Snap.Snaplet.Session.SessionManager

Description

This module is meant to be used mainly by Session backend developers, who would naturally need access to ISessionManager class internals. You can also use it if you need low-level access to the backend functionality.

Synopsis

- data SessionManager = forall a . ISessionManager a => SessionManager a
- class ISessionManager r where
  - load :: r -> Snap r
  - commit :: r -> Snap ()
  - reset :: r -> Snap r
  - touch :: r -> r
  - insert :: Text -> Text -> r -> r
  - lookup :: Text -> r -> Maybe Text
  - delete :: Text -> r -> r
  - csrf :: r -> Text
  - toList :: r -> [(Text, Text)]

# Documentation

data SessionManager

Any Haskell record that is a member of the `ISessionManager` typeclass can be stuffed inside a `SessionManager` to enable all session-related functionality.

To use sessions in your application, just find a Backend that would produce one for you inside of your `Initializer`. See `initCookieSessionManager` in `CookieSession` for a built-in option that would get you started.

Constructors

forall a . ISessionManager a => SessionManager a |

class ISessionManager r where

Methods

load :: r -> Snap r

Load a session from given payload.

Will always be called before any other operation. If possible, cache and do nothing when called multiple times within the same request cycle.

commit :: r -> Snap ()

Commit session, return a possibly updated paylaod

reset :: r -> Snap r

Reset session

touch :: r -> r

Touch session

insert :: Text -> Text -> r -> r

Insert a key-value pair into session

lookup :: Text -> r -> Maybe Text

Lookup a key in session

delete :: Text -> r -> r

Delete a key in session

csrf :: r -> Text

Return a session-specific CSRF protection token. See `mkCSRFToken` for help in creating the value.

toList :: r -> [(Text, Text)]

Return all key-value pairs as an association list