 
 (defn session-response
   "Updates session based on :session key in response."
-  [response & [opts]]
-  (-> response
-      (bare-session-response opts)
-      cookies/cookies-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

      (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)

  ([handler options]
     (let [options (session-options options)]
       (fn [request]
         (let [new-request (session-request request options)]
           (-> new-request
               handler
               (session-response new-request options)))))))
