Biscotti.Cookie
- Package
- purescript-biscotti-cookie
- Repository
- drewolson/purescript-biscotti-cookie
This module allows parsing and generating cookie headers. You'll generally use
the Cookie.new
function to create a cookie from a name/value pair and the
Cookie.set*
functions to set attributes on a cookie.
Cookie.stringify
generates the string representation of a cookie, suitable for
writing to an HTTP header.
Cookie.parse
parses the string representation of a cookie, returning an
Either ParseError Cookie
.
import Biscotti.Cookie as Cookie
> Cookie.stringify $ Cookie.setSecure $ Cookie.new "key" "value"
key=value; Secure
> Cookie.parse "key=value; Secure"
(Right { name: "key", value: "value", secure: true, ... })
Re-exports from Biscotti.Cookie.Generator
Re-exports from Biscotti.Cookie.Parser
#parseMany Source
parseMany :: String -> Either ParseError (List Cookie)
Parses a String
into an Either ParseError (List Cookie)
.
HTTP requests can include multiple cookies in a single
Cookie
header consisting of only name/value pairs. This
function can be used to parse this header.
> parseMany "key1=value1; key2=value2"
(Right ({ name: "key1", value: "value1", ... } : { name: "key2", value: "value2", ... } : Nil))
#parse Source
parse :: String -> Either ParseError Cookie
Parses a String
into an Either ParseError Cookie
. This
function is primarily intended to parse the Set-Cookie
header on the client.
> Parser.parse "key=value; Secure"
(Right { name: "key", value: "value", secure: true, ... })
Re-exports from Biscotti.Cookie.Types
#setHttpOnly Source
setHttpOnly :: Cookie -> Cookie
#getHttpOnly Source
getHttpOnly :: Cookie -> Boolean