Using the Session
The functions and macros to manipulate sessions are defined in the
REBLOCKS/SESSION package.
Session initialization
When a new user opens the site in a browser, Reblocks does these steps:
Creates a new session object. You can consider it a hash table where some data can be stored.
Generates a unique
IDand puts this session object in the hash map of all sessions.Calls the
init-sessiongeneric function to determine which widget should be shown to the user.Renders the root widget to
HTMLand sends it to the browser.Along with this
HTMLresponse, sends theSet-Cookieheader to save the sessionIDin the browser.
The method you define for the init-session generic function should return a root widget.
This widget may include children and render them in its
reblocks/widget:render generic function implementation.
You will find an example of init-session in the Quickstart section.
Storing data
You can store any kind of data in a session.
To set a value, use (SETF GET-VALUE) function.
For example, you might want to store information about the current user if they logged in: