How to set Spring Boot Tomcat session timeout

By | 2018-09-15T13:05:03+00:00 February 18th, 2018|Spring Boot|3 Comments

In this tutorials, I am going to show how to set/change Tomcat session timeout in Spring boot application.

Spring Boot Tomcat session timeout :

We should be able to set the server.session.timeout in application.properties or application.yml file.

application.prroperties
server.session.timeout = 5000 // Session timeout in seconds

Most of the cases the above configuration will work, If not you should set the cookie max age along with session time out like below.

application.prroperties
server.session.cookie.max-age=5000
server.session.timeout=5000

Reference :

Spring boot config

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

3 Comments

  1. ekassouroko@gmail.com'
    Enoch May 22, 2018 at 1:57 pm - Reply

    Hi chandrashekhar,
    I ´ve just used the server.session.timeout in my application.properties file and it worked. Thanks

  2. kondaveetikrishna13@gmail.com'
    krishna September 13, 2018 at 11:58 pm - Reply

    Hi
    in my spring boot application i have configured both server.session.cookie.max-age=60 and server.session.timeout=60.
    but still the session is not getting expired. i am not sure whether i am missing other configuration..

  3. dezenzio@bellsouth.net'
    PJD November 7, 2018 at 1:19 am - Reply

    Krishna, it depends on what version of Spring Boot you are using. The server.session.timeout no longer works in Spring 2.x, which requires server.servlet.session.timeout. Keep in mind this will only work in embedded Tomcat, not standalone. For that, you have to manually set the session timeout in the Tomcat server.xml. Having said all that, my session also doesn’t timeout even when setting it to 2 minutes and waiting 5 minutes. I’ve tried all the settings related to this and so far nothing works. That’s why I’m read this page.

Leave A Comment