   (fn [app-state [_ token]]
     (if (not-empty token)
       (dispatch [:set-message ""]))
-    (set-cookie :token token)
+    (cookies/set! :token token)
     (-> app-state
         (assoc-in [:credentials :token] token)
         (assoc-in [:ui-state :section] (if (empty? token) :login :write))




;;;;
;;;; Helpers
;;;;

(defn set-cookie [k v]
  (aset js/document "cookie" (str (name k) "=" v)))

(defn get-cookie [k]
  (let [cookie (aget js/document "cookie")
        as-map (->> (split cookie #";")
                    (map trim)
                    (map #(split % #"="))
                    (map #(if (= 1 (count %))
                           [(first %) nil]
                           %))
                    (into {})
                    (clojure.walk/keywordize-keys))]
    (k as-map)))


;;;;------------------------------
;;;; Queries
;;;;------------------------------

(register-handler
  :initialize
  (fn [app-state _]
    (dispatch [:set-token (cookies/get :token nil)])
    (merge app-state {:ui-state {:is-busy?      false
                                 :section       :login
                                 :current-query ""
