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

Safe HaskellNone
LanguageHaskell98

Happstack.Server.Cookie

Description

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

Synopsis

Documentation

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.

Constructors

Session

session cookie - expires when browser is closed

MaxAge Int

life time of cookie in seconds

Expires UTCTime

cookie expiration date

Expired

cookie already expired

mkCookie Source

Arguments

:: 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.

example

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."