简体   繁体   English

是否可以杀死Tomcat中的会话或强制会话过期(无论是活动的还是非活动的)?

[英]Is it possible to kill session or force session expiry in Tomcat either active or inactive?

I need to know if its possible to set a forced session time-out at a WEB SERVER level, that basically after x period of time, kicks the user from the session either it is active or inactive or better saying WEBSERVER to delete the session linked to the client. 我需要知道是否有可能在WEB SERVER级别上设置强制会话超时,即基本上在x一段时间后,它将用户从会话中踢出了活动状态还是非活动状态,或者更好地说WEBSERVER删除链接的会话给客户。 Can this be achieved without development intervention on the application side? 是否可以在没有应用程序方面的开发干预的情况下实现? Is this possible to do it with Tomcat? 使用Tomcat可以做到吗? Thank you. 谢谢。

You can do it through Tomcat default web.xml configuration 您可以通过Tomcat默认的web.xml配置来完成此操作

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

For full reference: https://tomcat.apache.org/tomcat-5.5-doc/appdev/web.xml.txt 有关完整参考: https : //tomcat.apache.org/tomcat-5.5-doc/appdev/web.xml.txt

The file can be located in conf/web.xml (relative to your tomcat installation) 该文件可以位于conf / web.xml中(相对于您的tomcat安装)

Edit 编辑

You can also invalidate a given session using session.invalidate() method 您还可以使用session.invalidate()方法使给定会话无效

you can set the time when you create a session using setMaxInactiveInterval(int interval); 您可以使用setMaxInactiveInterval(int interval);设置创建会话的setMaxInactiveInterval(int interval); either make it constant or fetch from database depending on users time..! 使其恒定或根据用户时间从数据库中获取..!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM