server.session-timeout seems to be working only for embedded tomcat.
I put a log statement to check the session max interval time. After deploying the
Complementing the @Ali answer, you can also create a session.timeout variable in your application.yml file and use it in your class. This should work great with Spring Boot war and external Tomcat:
application.yml
session:
timeout: 480 # minutes
SessionListener (with @Configuration annotation)
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
class SessionListener implements HttpSessionListener {
@Value("${session.timeout}")
private Integer sessionTimeout;
@Override
public void sessionCreated(HttpSessionEvent event) {
event.getSession().setMaxInactiveInterval(sessionTimeout);
}
@Override
public void sessionDestroyed(HttpSessionEvent event) {}
}