Getting Started
Core
Relational Databases
NoSQL Databases
Cache
Internationalization
REST Client
Scheduler
Sendmail
Template
Virtual File Storage
Web
Testing
Advanced
If you need to store data between HTTP requests, you can store it in the session. The data stored in the session is available throughout the user’s session.
The following configuration keys can be used in the configuration file of your application.
voidframework.web.session.cookieName
the name of the cookie containing the current session. The default value is VOID_SESS
.voidframework.web.session.cookieHttpOnly
is the cookie only be accessed via HTTP? The default value is true
.voidframework.web.session.cookieSecure
is the cookie secured? If true, sent only for HTTPS requests. The default value is false
.voidframework.web.session.signatureKey
the key used to digitally sign the session content.voidframework.web.session.timeToLive
the session TTL. The default value is 7 days
.You can access the session data via the Context
. Methods get
or getOrDefault
can be used.
@Singleton
@WebController
public class Controller {
@RequestRouting
public Result sessionExample(final Context ctx) {
final String userId = ctx.getSession().get("USER_ID");
return Result.of(userId);
}
}
To store value(s), methods put
, putAll
and putIfAbsent
can be used.
@Singleton
@WebController
public class Controller {
@RequestRouting
public Result sessionExample(final Context ctx) {
final String userId = ctx.getSession().put("USER_ID", "e90b88d4-3c15");
return Result.of(userId);
}
}