Search code examples
clojurering

how to debug the ring session store?


I've defined an app and wish to be able to print out all the values contained in session store is there a good way to do this?

(def app
  (-> #'handler
      (ring.middleware.stacktrace/wrap-stacktrace)
      (ring.middleware.session/wrap-session)))

Solution

  • You can specify the session store for wrap-session to use:

    (def all-the-sessions (atom {}))
    
    (def app
      (-> #'handler
        (ring.middleware.stacktrace/wrap-stacktrace)
        (ring.middleware.session/wrap-session {:store (ring.middleware.session.memory/memory-store all-the-sessions)))
    

    Now you can inspect the all-the-sessions atom.