   ([handler options]
      (let [options (session-options options)]
        (fn [request]
-         (let [new-request (session-request request options)
-               session-key (:session/key new-request)
-               response (-> new-request
-                            handler
-                            (assoc :session/key session-key))]
-           (when (seq (dissoc response :session/key))
-             (session-response response options)))))))
+         (let [new-request (session-request request options)]
+           (-> new-request
+               handler
+               (session-response new-request options)))))))

      (bare-session-request opts)))

(defn- bare-session-response
  [{session-key :session/key :as response} & [{:keys [store cookie-name cookie-attrs]}]]
  (let [new-session-key (when (contains? response :session)
                          (if-let [session (response :session)]
                            (store/write-session store session-key session)


(defn session-response
  "Updates session based on :session key in response."
  [response request & [opts]]
  (when response
    (-> response
        (bare-session-response request opts)
        cookies/cookies-response)))

(defn wrap-session
  "Reads in the current HTTP session map, and adds it to the :session key on
