Languages
[Edit]
EN

Spring Boot 2.x - change session cookie max-age (JSESSIONID)

10 points
Created by:
Violet-Hoffman
652

In this short article, we would like to show how to change JSESSIONID cookie max-age from Spring Boot 2.x application.properties file.

Quick solution (add a single line to your application.properties file):

Where: P365D means JSESSIONID cookie will be stored 365 days in the web browser.

Screenshot:

Spring Boot 2.x session expiration time set to 365 days (set in 2021-10-13) - displayed in Google Chrome DevTools
Spring Boot 2.x session expiration time set to 365 days (set in 2021-10-13) - displayed in Google Chrome DevTools

 

Example values:

  • P7D - 7 days,
  • P30D - 30 days,
  • P730D - around 2 years.

Oracle examples

Edit

The below examples come from official Oracle docs (java.time.Duration class).

References

Edit
  1. Duration - Oracle Docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join