Sessions provide a way to store information about a user across multiple requests. Currently, we support memory based sessions and Redis backed session but more options are coming.
To get an instance of the Session
simply add it as a parameter of your controller method.
public static void index(Session session) {
session.put("userid", 123);
}
To store data in the session simply call
session.put("key", "value");
To retrieve data from the session call.
session.get("key");
This will return the value as an instance of Object
. We provide helper methods to retrieve
the values as String etc...
session.getString("key");