Set session Expiration Time in Java (Spring Boot)

Source: Internet
Author: User

1. Spring Boot:

 server.session.cookie.comment = # comment Session cookie. Server . Session.cookie.domain = # session cookie domain. Server . session.cookie.http-only =# "HttpOnly" Flag is a session cookie. Server . session.cookie.max-age =. Session.cookie.name = # session cookie name. Server . Session.cookie. path  = # The path of the session cookie. Server . session.cookie.secure =. session.persistent = False # persists session data between reboots. Server . Session.store-dir  =. session.timeout = # Session timeout (seconds). Server . Session.tracking-modes =# Session tracking mode (one or more of the following: "Cookie", "url", "SSL"). 

2. The Web container, such as Tomcat, can set the timeout time to 30 minutes

3. Session-config configuration in Web. xml

The session-timeout element is used to specify the default session time-out interval, in minutes. The element value must be an integer. If the value of the session-timeout element is zero or negative, it means that the session will never time out. For example, set the session expiration time to 30 minutes:

< Session-config >      < Session-timeout ></session-timeout></session-config >

4, in the program call session Setmaxinactiveinterval method settings

Session.setmaxinactiveinterval (30 * 60);  

Setmaxinactiveinterval sets the expiration time for the current session, not the entire web time, in seconds. If the value is set to zero or negative, the session will never time out. Often used to set the current session time.

Reference:

http://blog.csdn.net/zuyi532/article/details/7536287

Set session Expiration Time in Java (Spring Boot)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.