9

I'm looking to extend the user session in a Spring MVC app with Spring boot and Tomcat. Looking at the documentation there seems to be 2 relevant properties:

server.servlet.session.timeout
spring.session.timeout

Most examples out there seem to suggest to use server.servlet.session.timeout; what is the purpose of spring.session.timeout? Which one should be used to extend the user session?

d0001
  • 2,162
  • 3
  • 20
  • 46

2 Answers2

11

spring.session.timeout is the property from a Spring sub-project called Spring Session. It will fallback to server.servlet.session.timeout if it is not set.

In short , Spring Session allows you to store HttpSession in RDBMS / Redis / Hazelcast Cluster / MongoDB rather than an internal map inside Tomcat .So the sessions is stored in the container agnostic way and make session clustering easier as you do not need to configure a Tomcat cluster.

So if you do not use Spring Session , you should use server.servlet.session.timeout

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
1

You should be able to set the server.session.timeout in your application.properties file to do the same

I think, If you add spring.session.timeout in application.properties the session timeout value mentioned using server.session.timeout will be overridden

Deepak Jain
  • 347
  • 1
  • 6