How can I configure my (embedded) Tomcat Session Timeout in a Spring Boot Application?
public class SessionListener implements HttpSessionListener{
@Override
public void sessionCreated(HttpSessionEvent se) { se.getSession().setMaxInactiveInterval(5*60);
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
}}I have a SessionListener but I have no idea in which class I have to add this Listener to the Context.
13 Answers
server.session.timeout in the application.properties file is now deprecated. The correct setting is:
server.servlet.session.timeout=60sAlso note that Tomcat will not allow you to set the timeout any less than 60 seconds. For details about that minimum setting see .
6- Spring Boot version 1.0:
server.session.timeout=1200 - Spring Boot version 2.0:
server.servlet.session.timeout=10m
NOTE: If a duration suffix is not specified, seconds will be used.
You should be able to set the server.session.timeout in your application.properties file.
ref:
EDIT:
This property has changed in later versions of Spring Boot to server.servlet.session.timeout.
ref:
2