mysnapsession-0.4: Sessions and continuations for Snap web apps

Snap.SessionUtil

Synopsis

Documentation

setCookie :: MonadSnap m => Cookie -> m ()Source

Sets a cookie in both the request and the response. This modifies the list of cookies in the request, so that later attempts to get cookies will find this one even within the same request.

lookupCookie :: MonadSnap m => ByteString -> m (Maybe Cookie)Source

Retrieves a cookie, looking first in the response map, and if not there, then in the request. This ensures that the most recently set cookie is retrieved.

clearCookie :: MonadSnap m => ByteString -> m ()Source

Clears a cookie. This involves setting the cookie to the empty string, with an expiration time in the past.

popPathTo :: MonadSnap m => (ByteString -> m a) -> m aSource

If there is another path component in the request path, pop it off, and pass it as a parameter to the handler.

ifTopDir :: MonadSnap m => m a -> m aSource

Ensure that we're at the top level of a request, and expect that it be a directory. As with standard HTTP behavior, if a path to a directory is given and the request URI doesn't end in a slash, then the user is redirected to a path ending in a slash.

ifTopFile :: MonadSnap m => m a -> m aSource

Ensure that we're at the top level of a request, and expect that it be a file. If a trailing slash is given, we pass on the request.

newtype SessionKey Source

Session keys are 64-bit integers with standard numeric type classes.

Constructors

K Word64 

uniqueKey :: (Random k, Ord k) => Map k a -> IO kSource

Generates a random key that is not already used in the given map. Though not technically speaking guaranteed to terminate, this should be fast in practice.