Spring Session
| This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 4.1.1! |
Spring Boot provides Spring Session auto-configuration for a range of data stores. For each data store, a specific Spring Boot starter is provided.
When building a servlet web application, the following stores can be auto-configured:
- Redis (
spring-boot-starter-session-data-redis) - JDBC (
spring-boot-starter-session-jdbc)
The servlet auto-configuration replaces the need to use @Enable*HttpSession.
When building a reactive web application, the Redis store can be auto-configured by depending on spring-boot-starter-session-data-redis.
This replaces the need to use @EnableRedisWebSession.
Each store has specific additional settings. For instance, it is possible to customize the name of the table for the JDBC store, as shown in the following example:
- Properties
- YAML
spring.session.jdbc.table-name=SESSIONS
spring:
session:
jdbc:
table-name: "SESSIONS"
For setting the timeout of the session you can use the spring.session.timeout property.
If that property is not set with a servlet web application, the auto-configuration falls back to the value of server.servlet.session.timeout.
To provide the timeout programmatically, define a SessionTimeout bean.
You can take control over Spring Session’s configuration using @Enable*HttpSession (servlet) or @EnableRedisWebSession (reactive).
This will cause the auto-configuration to back off.
Alternatively, depend on the relevant Spring Session module directly rather than using one of Spring Boot’s starters for Spring Session.
With either approach, Spring Session can then be configured using the annotation’s attributes rather than the previously described configuration properties.
- Related Spring Documentation
- Spring Boot
- Spring Framework
- Spring Cloud
- Spring Cloud Build
- Spring Cloud Bus
- Spring Cloud Circuit Breaker
- Spring Cloud Commons
- Spring Cloud Config
- Spring Cloud Consul
- Spring Cloud Contract
- Spring Cloud Function
- Spring Cloud Gateway
- Spring Cloud Kubernetes
- Spring Cloud Netflix
- Spring Cloud OpenFeign
- Spring Cloud Stream
- Spring Cloud Task
- Spring Cloud Vault
- Spring Cloud Zookeeper
- Spring Data
- Spring Integration
- Spring Batch
- Spring Security
- Spring AI
- Spring AMQP
- Spring CLI
- Spring GraphQL
- Spring for Apache Kafka
- Spring Modulith
- Spring for Apache Pulsar
- Spring Shell All Docs...
