signed-cookies: Secure cookie implementation for Scotty web framework

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.



Please see

[Skip to ReadMe]


Change logNone available
Dependenciesattoparsec, base (>=2 && <5), base64-bytestring, bytestring, scotty, SHA, signed-cookies, text, wai [details]
Copyright2017 Kyle Gwinnup
AuthorKyle Gwinnup
Home page
Bug tracker
Source repositoryhead: git clone
UploadedSat Feb 4 16:23:09 UTC 2017 by kgwinnup



Maintainers' corner

For package maintainers and hackage trustees

Readme for signed-cookies-

[back to package description]

Signed Cookies for Scotty Web Framework

The signed-cookies package exports two functions setCookie and getCookie. Besure to use the same signing key.


{-# LANGUAGE OverloadedStrings #-}

module Main where

import Web.Scotty
import Web.Scotty.Internal.Types (ActionError(Next))
import Data.Text.Lazy (fromStrict, Text, pack, toStrict)

import Web.Scotty.SignedCookies

singleCookie = do
  setCookie "secret" "key" "value"
  setCookie "secret" "key2" "value2"
  text "single cookie"

readCookies = do
  cs <- header "Cookie"
  h <- getCookie "secret" "key"
  text $ pack . show $ h

main :: IO ()
main = scotty 3000 $ do
  get "/" singleCookie
  get "/read" readCookies