 (defn- get-request-session
   "Retrieve the session using the 'session' cookie in the request."
   [request]
-  (if-let [session-id (-> request :cookies :session)]
-    (read-session session-id)))
+  (if-let [session-data (-> request :cookies :session)]
+    (read-session session-data)))
 
 (defn- assoc-request-session
   "Associate the session with the request."


(defn- set-session-cookie
  "Set the session cookie on the response."
  [request response session]
  (let [new?   (:new-session? request)
        cookie (session-cookie new? session)
        update (set-cookie :session cookie, :path "/")]
    (if cookie
      (update-response request response update)

  ([handler session-type]
    (fn [request]
      (binding [*session-type* session-type]
        (let [request  (-> request assoc-cookies
                                   assoc-request-session
                                   assoc-request-flash)
              response (handler request)]
          (when response
            (if (or (:session response) (:new-session? request))
              (write-session (:session response))
              (if (not-empty (:flash request))
                (write-session (:session request))))
            (set-session-cookie request response)))))))

;; User functions for modifying the session

