2
votes

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)))
1
You can do this in specific cases (e.g., a memory store that you have in scope somewhere), but not in general. E.g., how would it be possible to get all sessions when using cookie storage? The only place that session data exists is in each user's browser. - Francis Avila

1 Answers

5
votes

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.