HttpSessionManager

Default SessionManager backed by the servlet HTTP session.

Stores the caller's SessionDetails as a session attribute under attributeKey. On create, ensures a session exists and (when rotateSessionIdOnCreate is true) rotates the session id via HttpServletRequest.changeSessionId() to defend against session fixation. On invalidate, clears the attribute and (when invalidateSessionOnDestroy is true) calls HttpSession.invalidate().

validate never creates a session — it only reads the current session, preserving the "no credentials → anonymous" contract of the extension.

The stored SessionDetails.identity must be Serializable so it can travel with the session when the container uses a distributed session store. create rejects non-serializable identities with IllegalArgumentException — surface the failure at create time rather than at replication time. Prefer enum io.javalin.security.RouteRoles (enums are serializable) when sessions may be replicated.

Types

Link copied to clipboard
class Builder

Fluent builder for HttpSessionManager.

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun create(context: Context, details: SessionDetails)

Establishes a session for details on the current request.

Link copied to clipboard
open override fun invalidate(context: Context)

Destroys the current session, if any.

Link copied to clipboard
open override fun validate(context: Context): SessionDetails?

Returns the SessionDetails associated with the current request, or null when no valid session exists.