Spring Why session get expired before session-time

2019-07-22 17:17发布

问题:

I am using Spring security authentication and after successful logis is session set. I have configured session-timeout on 10 minutes, but session is removed after few minutes. I don't know why.

Here is debug output:

2013-09-13 12:34:29 DEBUG HttpSessionEventPublisher:83 - Publishing event: org.springframework.security.web.session.HttpSessionDestroyedEvent[source=org.apache.catalina.session.StandardSessionFacade@5d67c24a]
2013-09-13 12:34:29 DEBUG SessionRegistryImpl:156 - Removing session CA174F1B4B889FFDBF47E22C7C4D5A0B from principal's set of registered sessions
2013-09-13 12:34:29 DEBUG SessionRegistryImpl:164 - Removing principal org.springframework.security.core.userdetails.User@d50fea1e: Username: tester; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_MANAGER,ROLE_USER from registry

web.xml

<session-config>
    <session-timeout>10</session-timeout>
</session-config>

回答1:

Session timeout can be overridden by various means. See http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int). Make sure there isn't anything else that is overriding it (Web/App server, framework, ...).