IDEA JeeSite框架httpSession.invalidate()無效問題解決方案
想要實現一個功能:同一個用戶在兩個不同的瀏覽器中登錄,后面的踢掉之前的登錄。
本來的思路是在httpSession監聽器中進行判斷。但是在使用httpSession.invalidate();銷毀Session的時候,這一句話會拋出奇怪的異常,怎么都解決不了。
這個時候可以使用一個比較笨的但是有效的一個方法來替代:
httpSession.setMaxInactiveInterval(1);
在代碼中設置過期時間為1秒鐘
當然這個方法只是耍小聰明,后來發現,我遇到的問題,實際上是JeeSite 框架集成了Shiro 登陸框架,而這個框架,已經默認實現了之前描述的功能,在它自定義的登錄登出攔截器中。
<!-- 定義Shiro安全管理配置 --> <bean class='org.apache.shiro.web.mgt.DefaultWebSecurityManager'> <property name='realm' ref='systemAuthorizingRealm' /> <property name='sessionManager' ref='sessionManager' /> <property name='cacheManager' ref='shiroCacheManager' /> </bean> <!-- 自定義會話管理配置 --> <bean class='com.thinkgem.jeesite.common.security.shiro.session.SessionManager'> <property name='sessionDAO' ref='sessionDAO'/> <!-- 會話超時時間,單位:毫秒 --> <property name='globalSessionTimeout' value='${session.sessionTimeout}'/> <!-- 定時清理失效會話, 清理用戶直接關閉瀏覽器造成的孤立會話 --> <property name='sessionValidationInterval' value='${session.sessionTimeoutClean}'/> <property name='sessionValidationSchedulerEnabled' value='true'/> <property name='sessionIdCookie' ref='sessionIdCookie'/> <property name='sessionIdCookieEnabled' value='true'/> </bean>
只需要修改屬性文件jeesite.properties 中的屬性即可
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章:
1. php測試程序運行速度和頁面執行速度的代碼2. ASP中常用的22個FSO文件操作函數整理3. 三個不常見的 HTML5 實用新特性簡介4. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報錯問題分析5. ASP調用WebService轉化成JSON數據,附json.min.asp6. SharePoint Server 2019新特性介紹7. React+umi+typeScript創建項目的過程8. 無線標記語言(WML)基礎之WMLScript 基礎第1/2頁9. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執行過程解析10. php網絡安全中命令執行漏洞的產生及本質探究
