This is how I save it during login:
(defn set-loggedin [username]
(sesh/put! :username username))
(defn login-handler [username password]
(let [user (datab/login username password)]
(if (empty? user)
(view/login-form "Wrong password.")
(do
(set-loggedin username)
(resp/redirect "/movies")))))
(defroutes app-routes
...
(POST "/" [username password] (login-handler username password))
(POST "/movie/save" [movieID name] (film-new movieID name))
...)
(def app
(noir-middleware/app-handler
[app-routes]
:ring-defaults (assoc-in site-defaults [:security :anti-forgery] false)))
When I show the username on the form after the login, it shows it, but when I try to save the movie (movie table has a column username) and get the username it is nil.
(defn film-new [movieID name]
(datab/filmnew movieID name (sesh/get :username))
(resp/redirect "/movies")
)
Am i wrapping the session wrong? I don't get it. I have also tried to wrap it like this
def app (sesh/wrap-noir-session*
(noir-middleware/app-handler [app-routes]
:ring-defaults (assoc-in site-defaults [:security :anti-forgery]
false))))
EDIT: libnoir is now officially deprecated. Start here.
This is a minimal example to show that libnoir's stateful session works out of the box:
If you could provide a minimal reproduction to show that your code is NOT working as expected, we could help you further. Having said that, libnoir looks a bit abandoned to me. You might be better of starting with vanilla Ring.