1

For my login system, I need to implement session data for different functionality when users are logged in or not.

I've only ever done sessions in flask, and google searches don't reveal a lot (or, more likely, I'm searching the wrong things). I have two questions:

  1. Is there a canonical way to do session data in Clojure and can this specifically done in http-kit?
  2. Is an atom enough, or would this be bad practice?
Jack Gee
  • 136
  • 6
  • 1
    IDK about http-kit but you can definitely do sessions in ring https://ring-clojure.github.io/ring/ring.middleware.session.html – Jared Smith Oct 12 '22 at 18:46

1 Answers1

0

sessions will have to be managed via ring. http-kit is a server & will only use the ring spec for requests and responses.

To fetch the session

(get-in req [:session :auth-token])

To add a session to your ring response

(assoc res
       :session {:auth-token auth-token
                 :userid (:id json-data)
                 :username (:username json-data)})
kopos
  • 406
  • 6
  • 12