Spring Security creates a session upon successful login by default and offers explicit configuration for limiting and controlling concurrent sessions per user, preventing account sharing or stale sessions from lingering.
A banking app configures maximumSessions(1) with maxSessionsPreventsLogin(false), so logging in on a new device automatically invalidates the session on the old device rather than blocking the new login.
http.sessionManagement(session -> session
.maximumSessions(1)
.maxSessionsPreventsLogin(false)
.expiredUrl("/login?expired"));A concise interview answer is
Spring Security creates a session at login and lets me control concurrency through sessionManagement().maximumSessions(), which caps how many active sessions a user can have and decides whether a new login blocks or the oldest session gets expired. SessionRegistry lets me inspect or force-expire specific sessions if needed.
Last updated: 16 July 2026
Previous question: What is the purpose of the Spring Security filter chain, and how do you add or customize a filter in it?