Session management in Spring Boot security governs how a user's authenticated state is tracked across requests, ranging from fully stateless token-based APIs to traditional server-side sessions with configurable lifecycle rules.
A REST API for mobile clients sets SessionCreationPolicy.STATELESS since JWTs carry all needed auth info, while an internal admin web console keeps default session-based login with a 30-minute idle timeout.
http
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.maximumSessions(1)
.maxSessionsPreventsLogin(true));A concise interview answer is
Spring Security supports both stateless and session-based models. For REST APIs I set SessionCreationPolicy.STATELESS since tokens carry auth info on every request. For web apps I configure session creation, timeouts, and concurrent session limits through the sessionManagement DSL to control how many active sessions a user can hold.
Last updated: 16 July 2026
Previous question: Explain how Spring Security integrates with OAuth2 for authentication and authorization.
Next question: How can you implement authentication and authorization in Spring Boot?