Interacting with the session
Fetching and retrieving information to and from the session in noir
is easy. The noir.session
namespace is our main interface, which mostly contains functions to store and retrieve data in the session, as well as some wrappers and cleanup functions. Initially, a noir session is just an empty map.
We can store data in the current session by entering the following:
(require '[noir.session :as session]) (session/put! :foo "baaaaaaaarrrrrrr!") >> {:foo "baaaaaaaarrrrrrr"}
We can then retrieve a value from the session using get
, as in the following:
(session/get :foo) >> "baaaaaaaarrrrrrr"
We can also use assoc-in!
to associate a nested key/value pair, and any level that doesn't exist will be initialized as an empty map on our behalf:
(session/assoc-in! [:some :nested] "hey there, I need some air down here.") >> {:foo "baaaaaaaarrrrrrr" :some {:nested "hey there, I need some air down here."}}
Likewise, we can retrieve the nested structure by using get-in...