【问题标题】:Spring Why session get expired before session-timeout?Spring 为什么会话在会话超时之前过期?
【发布时间】:2013-09-18 01:38:00
【问题描述】:

我正在使用 Spring 安全身份验证,并在成功登录后设置会话。我在 10 分钟内配置了 session-timeout,但几分钟后会话被删除。我不知道为什么。

这里是调试输出:

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>

【问题讨论】:

标签: java spring session session-timeout


【解决方案1】:

可以通过多种方式覆盖会话超时。 见http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int)。 确保没有其他任何东西覆盖它(Web/App 服务器、框架等)。

【讨论】:

  • 我正在使用 apache tomcat 但 web.xml 中有值 30。
  • 您使用的是最新版本的 tomcat 吗?您是否使用了可以覆盖超时的过滤机制?
猜你喜欢
  • 2018-12-14
  • 1970-01-01
  • 2023-04-07
  • 2014-01-22
  • 2013-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多