How to set Spring Boot Tomcat session timeout

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

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 or application.yml file.

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.


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+ ,


    Enoch May 22, 2018 at 1:57 pm - Reply

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

    krishna September 13, 2018 at 11:58 pm - Reply

    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..

    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.

    Bob March 5, 2019 at 3:47 am - Reply

    Not working for me too in Spring 3.x
    timeout: 60
    max-age: 60

Leave A Comment