ACEGI @ ConcurrentSessionFilter

本文探讨了并发会话控制器中过滤器的工作原理及其在管理过期会话信息方面的作用。详细介绍了如何避免过期会话永久存在的问题,并讨论了在会话失效后清理上下文的重要性。此外,还涉及了在请求过程中如何正确使用getSession方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

this filter must be first in the filter chan.it use for concurrentSessionController.in ConcurrentSessionFilter,u must remove the expired
session info,other wise the expired ie will expired for ever.
(because some times after
session.invalidate(),the HttpSession session = httpRequest.getSession(false) not null.I don't know weathe is the problem of the
servlet)

and it also set the session.invalidate(),this will clear the context in the session.

the HttpSessionContextIntegrationFilter will create a new security
context in the session or get the security context from the session
if the session is not invalidate. SecurityContextHolder.setContext
will invoked each request because it may be that in the filter chain the context in SecurityContextHolder has chaned.

I see some people invokeing sessionRegistry.removeSessionInformation(session.getId()); in the logout filter.it seems needless.


[code]getSession
public HttpSession getSession(boolean create)Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.

To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.

[/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值