-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Flexible session middleware for WAI
--   
--   Provides a generic, cookie-based middleware for sessions that is
--   parameterised over the session store, the cookie name, and the cookie
--   parameters (such as path, expiry, etc). Passes a pair of functions
--   (lookup key, set key) for the current session through the <a>Vault</a>
--   in the <a>Request</a>.
--   
--   Also provides a simple example session store based on threadsafe
--   <a>IORef</a>s and <a>Data.Map</a>.
--   
--   See example/Main.hs in git for example usage.
@package wai-session
@version 0.3.3

module Network.Wai.Session

-- | Type representing a single session (a lookup, insert pair)
type Session m k v = ((k -> m (Maybe v)), (k -> v -> m ()))

-- | A <a>SessionStore</a> takes in the contents of the cookie (if there
--   was one) and returns a (<a>Session</a>, <a>IO</a> action to get new
--   contents for cookie) pair
type SessionStore m k v = (Maybe ByteString -> IO (Session m k v, IO ByteString))

-- | Fully parameterised middleware for cookie-based sessions
withSession :: SessionStore m k v -> ByteString -> SetCookie -> Key (Session m k v) -> Middleware

-- | Simple session ID generator using cryptographically strong random IDs
--   
--   Useful for session stores that use session IDs.
genSessionId :: IO ByteString

module Network.Wai.Session.Map

-- | Simple session store based on threadsafe <a>IORef</a>s and <a>Map</a>.
--   This only works if your application server remains running (such as
--   with warp). All data is lost when the server terminates (bad for CGI).
--   
--   WARNING: This session is vulnerable to sidejacking, use with TLS for
--   security.
mapStore :: (Ord k, MonadIO m) => IO ByteString -> IO (SessionStore m k v)

-- | Store using simple session ID generator based on time and
--   <a>Unique</a>
mapStore_ :: (Ord k, MonadIO m) => IO (SessionStore m k v)
