我想知道你是 you are following the correct path
因为用户会话无效
usersSessions.forEach((session) -> { sessionRegistry.getSessionInformation(session.getId()).expireNow(); });注意事项
SessionInformation.expireNow()
并不意味着要从
redis数据库中删除条目,它只是将您已提到的过期属性附加到会话。
但是,这如何使用户会话无效?
这是ConcurrentSessionFilter发挥作用的地方,
.doFilter()方法实现了
automatically logging out
这是 ConcurrentSessionFilter* 的代码段 *
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; HttpSession session = request.getSession(false); if (session != null) { SessionInformation info = sessionRegistry.getSessionInformation(session .getId()); if (info != null) { if (info.isExpired()) { // Expired - abort processing doLogout(request, response); String targetUrl = determineExpiredUrl(request, info); if (targetUrl != null) { redirectStrategy.sendRedirect(request, response, targetUrl); return; } else { response.getWriter().print( "This session has been expired (possibly due to multiple concurrent " + "logins being attempted as the same user)."); response.flushBuffer(); } return; } else { // Non-expired - update last request date/time sessionRegistry.refreshLastRequest(info.getSessionId()); } } } chain.doFilter(request, response);}为此加油!



