Liking cljdoc? Tell your friends :D

Cookies Effects Handler for re-frame

Oh cookie, yummy! - KVN, Final Space

Herein a re-frame "Effects Handler", which enables various cookie operations using

Quick Start

1. Add Dependency

Clojars Project

2. Registration & Use

Note: Due to recent breaking changes to ClojureScript 1.9's use of spec, version 0.0.2 of this library requires that you use ClojureScript 1.9.542 or later

In the namespace where you register your event handlers, prehaps called handlers.cljs, you have two things to do:

First, add this require to the ns:

(ns app.handlers
    []    ;; <-- add this

Event handlers

Second, write an event handler which uses this effect:

  (fn [{:keys [db]} _]
    {:cookie/set {:name "cookie-monster-says"
                  :value "Om Nom Nom Nom!"}}))

Other supported effects include the below which are documented in the source:

  • :cookie/remove
  • :cookie/clear

Besides :name and :value, you can supply :on-success and :on-failure handlers as well as the usual cookie options including :max-age, :path, :domain, and :secure. See details and documentation in the source.


To use a coeffect:

  [(inject-cofx :cookie/get [:cookie-monster-says])]
  (fn [{db :db cookies :cookie/get} _]

Other supported coeffects include the below which are documented in the source:

  • :cookie/enabled?
  • :cookie/empty?
  • :cookie/keys
  • :cookie/values
  • :cookie/count



Copyright © 2016 SMX Ltd.

Distributed under the Eclipse Public License, the same as Clojure.

Can you improve this documentation? These fine people already did:
Andrew Kravchuk, David Goldfarb & Isaac Johnston
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close