cgi-utils-0.1: Simple modular utilities for CGI/FastCGI (sessions, etc.)

Network.CGI.Session

Contents

Synopsis

Types

data Session Source

A session consists of a unique id and a map.

Constructors

Session 

Instances

type Sessions = MVar ([Integer], Map Integer Session)Source

Sessions and unique ids are stored in an MVar.

type SessionName = StringSource

The cookie prefix (e.g. MYHASKELLCOOKIE).

type SessionM = StateT Session (CGIT IO)Source

A simple Session monad. Recommend you define your own.

Initialising and querying/updating

makeSessions :: IO SessionsSource

Make the sessions state.

initSession :: SessionName -> Sessions -> CGI SessionSource

Grab the session or create a new one.

updateSession :: Sessions -> Session -> CGI ()Source

Update a session in the map.

sessionId :: SessionM IntegerSource

Session value getter.

A simple Session monad.

runSessionCGI :: SessionName -> (CGI CGIResult -> IO ()) -> SessionM CGIResult -> IO ()Source

Initialise a session state and start a F/CGI process. This is a bit of a pattern so I've included it here for convenience.

runSession :: Sessions -> SessionM a -> Session -> CGI aSource

Simple session runner.

sessionIns :: (Read a, Show a) => String -> a -> (a -> a -> a) -> SessionM ()Source

Session value inserter/updater.

sessionDel :: String -> SessionM ()Source

Session value deleter.

sessionGet :: Read a => String -> SessionM (Maybe a)Source

Session value getter.

Utilities

makeSession :: SessionName -> Sessions -> CGI SessionSource

Create a new session and update the Mvar.

getSession :: SessionName -> Sessions -> CGI (Maybe Session)Source

Try to get the current session.