The default session timeout of a Spring Boot web application running with an embedded Tomcat server is 30 minutes. This means that if logged users are idle more than 30 minutes, they will be forced to log in again upon returning, as the server removes all timed-out users.

To change the session timeout for a Spring Boot application, simply specify the following property in the application configuration file (application.properties):

server.servlet.session.timeout= # Session timeout in seconds or minutes

For example, add the following line to the application configuration file to change session timeout to 15 minutes:

server.servlet.session.timeout=15m

The suffix “m” indicates that session timeout in minutes. If you don’t specify a suffix, Spring Boot will will interpret it as seconds. Let’s see another example:

server.servlet.session.timeout=300

This line sets the session timeout to 300 seconds or 5 minutes. It requires restart for the change take effect.

 

NOTES: If your Spring Boot application runs on an external Tomcat server, follow this post to learn how to change session timeout for external Tomcat instance.

 

References:

 

Related Spring Boot Posts:

 

Complete Spring Boot Tutorials


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment