This module implements the management of sessions. In particular, it defines a cookie that must be sent to the client in order to enable the handling of sessions. Based on sessions, this module also defines a session store that can be used by various parts of the application in order to hold some session-specific data.
Creates a cookie to hold the current session id. This cookie should be sent to the client together with every HTML page.
Checks whether the current user session is initialized, i.e., whether a session cookie has been already set.
withSessionCookie
:: HtmlPage -> IO HtmlPage
Decorates an HTML page with a session cookie.
withSessionCookieInfo
:: HtmlPage -> IO HtmlPage
Decorates an HTML page with a session cookie and shows an information page when the session cookie is not set.
data SessionStore _
The type of a session store which contains data of a particular type. The name of the session store is used to store the session data persistently in files.
sessionStore
:: (Read a, Show a) => String -> SessionStore a
The constructor for a session store containing readable and showable data where a unique store name must be provided. The name is used as a file name in the directory containing all session data.
getSessionMaybeData
:: (Read a, Show a) => SessionStore a -> FormReader (Maybe a)
Retrieves session data associates to the current user session.
Returns Nothing
if there is no data for the current session.
getSessionData
:: (Read a, Show a) => SessionStore a -> a -> FormReader a
Retrieves session data associated to the current user session where the second argument is returned if there is no data currently associated to the current session.
putSessionData
:: (Read a, Show a) => SessionStore a -> a -> IO ()
Stores session data associated to the current user session in the persistent session store.
removeSessionData
:: (Read a, Show a) => SessionStore a -> IO ()
Removes data associated to the current user session from the given session store.
modifySessionData
:: (Read a, Show a) => SessionStore a -> a -> (a -> a) -> IO ()
Modifies the session data associated to the current user session according to the update functions provided in the last argument.