hsp-0.2: HSP/Session.hs
-----------------------------------------------------------------------------
-- |
-- Module : HSP.Session
-- Copyright : (c) Niklas Broberg 2004,
-- License : BSD-style (see the file LICENSE.txt)
--
-- Maintainer : Niklas Broberg, d00nibro@dtek.chalmers.se
-- Stability : experimental
-- Portability : requires undecidable and overlapping instances
--
-- Defines the Session object available to HSP pages.
-----------------------------------------------------------------------------
module HSP.Session (
getSessionVar
, setSessionVar
, delSessionVar
, abandon
) where
import qualified HSP.Data.Session as S
import HSP.Data
-- | Retrieve the value of a session scope variable, if available.
getSessionVar :: String -> HSP (Maybe String)
getSessionVar key = do
sess <- getSession
doIO $ S.getVarValue sess key
-- | Insert or update the value of a session scope variable.
setSessionVar :: String -> String -> HSP ()
setSessionVar k v = do
sess <- getSession
doIO $ S.setVarValue sess k v
-- | Delete a session scope variable.
delSessionVar :: String -> HSP ()
delSessionVar k = do
sess <- getSession
doIO $ S.deleteVar sess k
abandon :: HSP ()
abandon = getSession >>= doIO . S.abandon