happstack-server-6.2.5: Web related tools and services.



Functions for creating, adding, and expiring cookies. To lookup cookie values see Happstack.Server.RqData.



data Cookie Source

a type for HTTP cookies. Usually created using mkCookie.

data CookieLife Source

Specify the lifetime of a cookie.

Note that we always set the max-age and expires headers because internet explorer does not honor max-age. You can specific MaxAge or Expires and the other will be calculated for you. Choose which ever one makes your life easiest.



session cookie - expires when browser is closed

MaxAge Seconds

life time of cookie in seconds

Expires UTCTime

cookie expiration date


cookie already expired



:: String

cookie name

-> String

cookie value

-> Cookie 

Creates a cookie with a default version of 1, empty domain, a path of /, secure == False and httpOnly == False

see also: addCookie

addCookie :: (MonadIO m, FilterMonad Response m) => CookieLife -> Cookie -> m ()Source

Add the Cookie to Response.


 main = simpleHTTP nullConf $
   do addCookie Session (mkCookie "name" "value")
      ok $ "You now have a session cookie."

see also: addCookies

addCookies :: (MonadIO m, FilterMonad Response m) => [(CookieLife, Cookie)] -> m ()Source

Add the list Cookie to the Response.

see also: addCookie

expireCookie :: (MonadIO m, FilterMonad Response m) => String -> m ()Source

Expire the named cookie immediately and set the cookie value to ""

 main = simpleHTTP nullConf $
   do expireCookie "name"
      ok $ "The cookie has been expired."