cgi-3001.5.1.0: A library for writing CGI programs

Copyright | (c) Bjorn Bringert 2004-2005 (c) Ian Lynagh 2005
License | BSD-style
Maintainer | John Chee <cheecheeo@gmail.com>
Stability | experimental
Portability | portable General server side HTTP cookie library. Based on <http://wp.netscape.com/newsref/std/cookie_spec.html>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Network.CGI.Cookie

Description

TODO

- Add client side stuff (basically parsing Set-Cookie: value)
- Update for RFC2109 http://www.ietf.org/rfc/rfc2109.txt

Synopsis

- data Cookie = Cookie {
  - cookieName :: String
  - cookieValue :: String
  - cookieExpires :: Maybe UTCTime
  - cookieDomain :: Maybe String
  - cookiePath :: Maybe String
  - cookieSecure :: Bool
  - cookieHttpOnly :: Bool
  }
- newCookie :: String -> String -> Cookie
- findCookie :: String -> String -> Maybe String
- deleteCookie :: Cookie -> Cookie
- showCookie :: Cookie -> String
- readCookies :: String -> [(String, String)]

# Documentation

data Cookie Source #

Contains all information about a cookie set by the server.

Constructors

Cookie |

Fields

- cookieName :: String

  Name of the cookie.

- cookieValue :: String

  Value of the cookie.

- cookieExpires :: Maybe UTCTime

  Expiry date of the cookie. If `Nothing`, the cookie expires when the browser sessions ends. If the date is in the past, the client should delete the cookie immediately.

- cookieDomain :: Maybe String

  The domain suffix to which this cookie will be sent.

- cookiePath :: Maybe String

  The path to which this cookie will be sent.

- cookieSecure :: Bool

  `True` if this cookie should only be sent using secure means.

- cookieHttpOnly :: Bool

  `True` to tell the client's browser to prevent client side scripts from accessing the cookie.

#### Instances

Instances details

Read Cookie Source # |
Instance details Defined in Network.CGI.Cookie Methods readsPrec :: Int -> ReadS Cookie Source # readList :: ReadS [Cookie] Source # readPrec :: ReadPrec Cookie Source # readListPrec :: ReadPrec [Cookie] Source #
Show Cookie Source # |
Instance details Defined in Network.CGI.Cookie Methods showsPrec :: Int -> Cookie -> ShowS Source # show :: Cookie -> String Source # showList :: [Cookie] -> ShowS Source #
Eq Cookie Source # |
Instance details Defined in Network.CGI.Cookie Methods (==) :: Cookie -> Cookie -> Bool Source # (/=) :: Cookie -> Cookie -> Bool Source #
Ord Cookie Source # |
Instance details Defined in Network.CGI.Cookie Methods compare :: Cookie -> Cookie -> Ordering Source # (<) :: Cookie -> Cookie -> Bool Source # (<=) :: Cookie -> Cookie -> Bool Source # (>) :: Cookie -> Cookie -> Bool Source # (>=) :: Cookie -> Cookie -> Bool Source # max :: Cookie -> Cookie -> Cookie Source # min :: Cookie -> Cookie -> Cookie Source #

newCookie Source #

Arguments

:: String | Name
-> String | Value
-> Cookie | Cookie

Construct a cookie with only name and value set. This client will expire when the browser sessions ends, will only be sent to the server and path which set it and may be sent using any means.

findCookie Source #

Arguments

:: String | Cookie name
-> String | Semicolon separated list of name-value pairs
-> Maybe String | Cookie value, if found

Get the value of a cookie from a string on the form `"cookieName1=cookieValue1;...;cookieName2=cookieValue2"`. This is the format of the `Cookie` HTTP header.

deleteCookie Source #

Arguments

:: Cookie | Cookie to delete. The only fields that matter are `cookieName`, `cookieDomain` and `cookiePath`
-> Cookie |

Delete a cookie from the client by setting the cookie expiry date to a date in the past.

showCookie :: Cookie -> String Source #

Show a cookie on the format used as the value of the Set-Cookie header.

readCookies Source #

Arguments

:: String | String to parse
-> [(String, String)] | Cookie name - cookie value pairs

Gets all the cookies from a Cookie: header value