Setting session timeout period with Spring Security 3.0
Asked Answered
R

2

51

I am using Spring Security 3.0 to authenticate with an LDAP server and I cannot figure out to set my own session timeout period. I believe that the default is 30 minutes but I need to set it to longer than that

Reamonn answered 22/3, 2011 at 0:0 Comment(0)
C
116

You can either set the session timeout (say 60 minutes) for all sessions in web.xml:

<session-config>
  <session-timeout>60</session-timeout>
</session-config>

or on a per-session basis using

session.setMaxInactiveInterval(60*60);

the latter you might want to do in a authorizationSuccessHandler.

<form-login authentication-success-handler-ref="authenticationSuccessHandler"/>
Cristiano answered 22/3, 2011 at 1:36 Comment(6)
session-timeout, that was it! Thanks a lotReamonn
Thanks session.setMaxInactiveInterval(60*60*24); This code sets 24 hour session time.Do
@Cristiano this implementation throwing msg stating "Full authentication is required to access this resource" can we change this message ?Negress
server.session.timeout= # Session timeout in seconds - for Spring BootDwaindwaine
session-config - should be added into web.xml fileHandcraft
What if I am using spring boot and dont have web.xml?Rubeola
D
3

If you are using Spring Boot you can do so by adding the following to the application.properties file:

server.session.cookie.max-age=<your_value_in_seconds>
Demeanor answered 3/1, 2018 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.