snaplet-typed-sessions-0.5: Typed session snaplets and continuation-based programming for the Snap web framework

Safe HaskellSafe-Infered

Snap.Snaplet.TypedSession

Description

This module provides the generic interface to the various typed session implementations, including both server-side and client-side typed sessions.

Synopsis

Documentation

class HasTypedSession v t | v -> t whereSource

The generic interface to typed session implementations. Both the client-side and server-side implementations of sessions implement the common interface specified here.

Methods

getSession :: Handler b v tSource

Retrieves the session for the current request, always creating it if necessary.

setSession :: t -> Handler b v ()Source

Stores a new value for the current session.

clearSession :: Handler b v ()Source

Completely clears the current session, removing all associated cookies and server-side storage if applicable.

touchSession :: Handler b v ()Source

Marks a session as recently used, resetting the session timeout counter.

withSession :: HasTypedSession v t => (t -> Handler b v a) -> Handler b v aSource

A convenience function for gaining access to the session. The session is touched and then passed to the nested Handler.

getFromSession :: (Ord k, HasTypedSession v (Map k a)) => k -> Handler b v (Maybe a)Source

Gets a named value from a session that happens to be a Map.

setInSession :: (Ord k, HasTypedSession v (Map k a)) => k -> a -> Handler b v ()Source

Sets a named value in a session that happens to be a Map.

deleteFromSession :: (Ord k, HasTypedSession v (Map k a)) => k -> Handler b v ()Source

Deletes a named value from a session that happens to be a Map.