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.
Author: Michael Hanus
Version: May 2021
sessionDataDir
:: String
The name of the local directory where the session data, e.g., cookie information, is stored. |
inSessionDataDir
:: String -> String
Prefix a file name with the directory where session data, e.g., cookie information, is stored. |
doesSessionExist
:: IO Bool
Checks whether the current user session is initialized, i.e., whether a session cookie has been already set. |
sessionCookie
:: IO PageParam
Creates a cookie to hold the current session id. |
withSessionCookie
:: HtmlPage -> IO HtmlPage
Decorates an HTML page with session cookie. |
withSessionCookieInfo
:: HtmlPage -> IO HtmlPage
Decorates an HTML page with session cookie and shows an information page when the session cookie is not set. |
emptySessionData
:: SessionData a
An initial value for the empty session data. |
sessionStore
:: (Read a, Show a) => String -> GlobalP (SessionData a)
A session store contains readable and showable data kept in a store with a given name. |
getSessionMaybeData
:: (Read a, Show a) => GlobalP (SessionData a) -> FormReader (Maybe a)
Retrieves data for the current user session stored in a session store. |
getSessionData
:: (Read a, Show a) => GlobalP (SessionData a) -> a -> FormReader a
Retrieves data for the current user session stored in a session store where the second argument is returned if there is no data for the current session. |
putSessionData
:: (Read a, Show a) => GlobalP (SessionData a) -> a -> IO ()
Stores data related to the current user session in a session store. |
modifySessionData
:: (Read a, Show a) => GlobalP (SessionData a) -> a -> (a -> a) -> IO ()
Modifies the data of the current user session. |
removeSessionData
:: (Read a, Show a) => GlobalP (SessionData a) -> IO ()
Removes data related to the current user session from a session store. |
The type of session data which represents the data used in a session. The session data consists of a list of data items for each session in the system together with the clock time of the last access. The clock time is used to remove old data in the store.
Constructors:
The type of a session store is a persistent global entity containing a session store with some data.
Type synonym: SessionStore a = GlobalP (SessionData a)
The name of the local directory where the session data, e.g., cookie information, is stored. For security reasons, the directory should be non-public readable.
|
Prefix a file name with the directory where session data, e.g., cookie information, is stored. |
Checks whether the current user session is initialized, i.e., whether a session cookie has been already set. |
Creates a cookie to hold the current session id. This cookie should be sent to the client together with every HTML page. |
Decorates an HTML page with session cookie. |
Decorates an HTML page with session cookie and shows an information page when the session cookie is not set. |
An initial value for the empty session data.
|
A session store contains readable and showable data kept in a store with a given name. The name is used as a file name in the directory containing all session data. |
Retrieves data for the current user session stored in a session store.
Returns |
Retrieves data for the current user session stored in a session store where the second argument is returned if there is no data for the current session. |
Stores data related to the current user session in a session store. |
Modifies the data of the current user session. |
Removes data related to the current user session from a session store. |