Module

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

#stringify Source

stringify :: Cookie -> String

Return the String representation of a Cookie.

> Generator.stringify $ Cookie.setSecure $ Cookie.new "key" "value"
key=value; Secure

Re-exports from Biscotti.Cookie.Parser

#parse Source

parse :: String -> Either ParseError Cookie

Parses a String into an Either ParseError Cookie.

> Parser.parse "key=value; Secure"
(Right { name: "key", value: "value", secure: true, ... })

Re-exports from Biscotti.Cookie.Types

#SameSite Source

data SameSite

Type representing a Cookie's optional SameSite attribute.

Constructors

Instances

#Cookie Source

#setMaxAge Source

#setHttpOnly Source

#new Source

new :: String -> String -> Cookie

The constructor for Cookie

#expire Source

expire :: Cookie -> Effect (Either String Cookie)

Expire an existing Cookie. This sets the Expires attribute of the cookie to yesterday's date.