Functions for creating, adding, and expiring cookies. To lookup cookie values see Happstack.Server.RqData.
- data Cookie = Cookie {
- cookieVersion :: String
- cookiePath :: String
- cookieDomain :: String
- cookieName :: String
- cookieValue :: String
- secure :: Bool
- httpOnly :: Bool
- data CookieLife
- mkCookie :: String -> String -> Cookie
- addCookie :: (MonadIO m, FilterMonad Response m) => CookieLife -> Cookie -> m ()
- addCookies :: (MonadIO m, FilterMonad Response m) => [(CookieLife, Cookie)] -> m ()
- expireCookie :: (MonadIO m, FilterMonad Response m) => String -> m ()
Documentation
a type for HTTP cookies. Usually created using mkCookie
.
Cookie | |
|
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.
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
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
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."