Storing session data
The note application is currently stateless. The entered data is displayed once and then it is lost. This is not useful. You need a place to store the data between requests. This place is the session. To use session, you have to instantiate SessionStore
at server startup. A class implementing the SessionStore
interface stores key/value pairs as an associative array. You start a session by calling the startSession()
method of the response object and terminate a session with the terminateSession()
method.
A cookie-based session is used by vibe.d. The session is available in the session
member of the request if you previously called the startSession()
method and if the client sends back a matching cookie.
The SessionStore
is an interface. If you are only running a single instance of your vibe.d server, then you can use the simple MemorySessionStore
implementation. If you use any kind of multiserver setup, then you need a persistent session store. The interface for the Redis...