Safe Haskell | None |
---|
- class SafeCopy st => ClientSession st where
- empty :: st
- data SessionConf = SessionConf {}
- mkSessionConf :: Key -> SessionConf
- data ClientSessionT st m a
- runClientSessionT :: Monad m => ClientSessionT st m a -> SessionConf -> m a
- getSession :: (Functor m, MonadPlus m, HasRqData m, ClientSession st) => ClientSessionT st m st
- putSession :: (Monad m, ClientSession st) => st -> ClientSessionT st m ()
- expireSession :: Monad m => ClientSessionT st m ()
- withSession :: (Functor m, MonadPlus m, HasRqData m, ClientSession st, Eq st) => State st a -> ClientSessionT st m a
- sessionPart :: (Functor m, Monad m, MonadIO m, FilterMonad Response m, ClientSession st) => ClientSessionT st m a -> ClientSessionT st m a
Documentation
class SafeCopy st => ClientSession st whereSource
Your session type must have an instance for this class.
data SessionConf Source
Configuration for the session cookie for passing to runClientSessionT
.
SessionConf | |
|
mkSessionConf :: Key -> SessionConfSource
Create a SessionConf
using defaults for everything except
sessionKey
. You can use record update syntax to override individual
fields.
main = do key <- getDefaultKey let sessConf = (mkSessionConf key) { sessionCookieLife = oneWeek } simpleHTTP nullConf $ runClientSessionT handlers sessConf where oneWeek = MaxAge $ 60 * 60 * 24 * 7 handlers = sessionPart $ msum [...]
data ClientSessionT st m a Source
Transformer for monads capable of using a session.
FilterMonad r m => FilterMonad r (ClientSessionT st m) | |
WebMonad r m => WebMonad r (ClientSessionT st m) | |
Monad m => Monad (ClientSessionT st m) | |
Functor m => Functor (ClientSessionT st m) | |
MonadPlus m => MonadPlus (ClientSessionT st m) | |
(Monad m, Functor m) => Applicative (ClientSessionT st m) | |
(Functor m, MonadPlus m) => Alternative (ClientSessionT st m) | |
Happstack m => Happstack (ClientSessionT st m) | |
(Monad m, HasRqData m) => HasRqData (ClientSessionT st m) | |
ServerMonad m => ServerMonad (ClientSessionT st m) | |
MonadIO m => MonadIO (ClientSessionT st m) |
runClientSessionT :: Monad m => ClientSessionT st m a -> SessionConf -> m aSource
Get the inner monad of a ClientSessionT
.
getSession :: (Functor m, MonadPlus m, HasRqData m, ClientSession st) => ClientSessionT st m stSource
Get the session value. If the cookie has not been decoded yet, it
will be decoded. If no session data is stored or the session has been
expired, empty
is returned.
putSession :: (Monad m, ClientSession st) => st -> ClientSessionT st m ()Source
Put a new value in the session.
expireSession :: Monad m => ClientSessionT st m ()Source
Expire the session, i.e. the cookie holding it.
withSession :: (Functor m, MonadPlus m, HasRqData m, ClientSession st, Eq st) => State st a -> ClientSessionT st m aSource
Run a State
monad with the session.
sessionPart :: (Functor m, Monad m, MonadIO m, FilterMonad Response m, ClientSession st) => ClientSessionT st m a -> ClientSessionT st m aSource
Wrapper around your handlers that use the session. Takes care of expiring the cookie of an expired session, or encrypting a modified session into the cookie.