session超时设置

具体设置很简单,方法有三种:

  (1)在主页面或者公共页面中加入:session.setMaxInactiveInterval(600);参数600单位是秒,即在没有10分钟活动后,session将失效。

  这里要注意这个session设置的时间是根据服务器来计算的,而不是客户端。所以如果是在调试程序,应该是修改服务器端时间来测试,而不是客户端。

  (2)也是比较通用的设置session失效时间的方法,就是在项目的web.xml中设置

  <!-- 设置session失效,单位分 -->

  <session-config>

  <session-timeout>1</session-timeout>

  </session-config> 
   // 设置为0,-1 表示永不超时

  (3)直接在应用服务器中设置,如果是tomcat,可以在tomcat目录下conf/web.xml中找到<session-config>元素,tomcat默认设置是30分钟,只要修改这个值就可以了。 
  在Tomcat的/conf/web.xml中session-config,默认值为:30分钟
    <session-config>
            <session-timeout>30</session-timeout>
      </session-config>
  需要注意的是如果上述三个地方如果都设置了,有个优先级的问题,从高到低:(1)>(2)>(3)

时间: 2024-08-04 18:16:51

session超时设置的相关文章

Java设置session超时(失效)的三种方式

1.      在web容器中设置(此处以tomcat为例) 在E:\apache-tomcat-7.0.54\apache-tomcat-7.0.54\conf\web.xml中设置,以下是apache-tomcat-7.0.54中的默认配置 <!-- ==================== Default Session Configuration ================= --> <!-- You can set the default session timeout 

Java-No.05 Java设置session超时(失效)的三种方式

1.在web容器中设置(此处以tomcat为例) 在tomcat-5.0.28\conf\web.xml中设置,以下是tomcat 5.0中的默认配置: <!-- ==================== Default Session Configuration ================= -->   <!-- You can set the default session timeout (in minutes) for all newly   -->   <!-

Java设置session超时(失效)的时间

在一般系统登录后,都会设置一个当前session失效的时间,以确保在用户长时间不与服务器交互,自动退出登录,销毁session具体设置的方法有三种:1.在web容器中设置(以tomcat为例)在tomcat-7.0\conf\web.xml中设置,以下是tomcat7.0中默认配置: <session-config> <session-timeout>30</session-timeout> </session-config> tomcat默认session

c# webConfig中的session超时详细设置

webConfig中的session超时详细设置 我们在webConfig中设置Session超时的时候,如果最后发行的地址是远程服务器,我们很多不是必须的属性并不用设置,如果设之后,倒不能让 session超时奏效.我在做现在的程序的时候,就是这样,写sessionState的时候,按照如下的方式设置之后,session设置的 timeout时间不能够起作用:但是不用了一些属性之后,就能够起作用了. 服务器上发行后不能起作用的设置: <sessionState mode="InProc&

Java设置session超时(失效)的三种方式 设置session的有效时间

1.      在web容器中设置(此处以tomcat为例) 在tomcat-5.0.28\conf\web.xml中设置,以下是tomcat 5.0中的默认配置: [html] view plain copy <!-- ==================== Default Session Configuration ================= --> <!-- You can set the default session timeout (in minutes) for 

Session管理之超时设置和强制下线

(一)Session超时时间设置的三种方式: (1)在web.xml中设置session-config <session-config> <session-timeout>2</session-timeout> </session-config> 即交互间隔时间最长为2分钟(该处时间单位为分钟),2分钟后session.getAttribute()获取的值为空. (2)在Tomcat的/conf/web.xml中session-config,默认值为:30分

你应该知道的那些超时设置或默认参数 good

defaultStatementTimeout Sets the number of seconds the driver will wait for a response from the database. Any positive integer Not Set (null) http://www.mybatis.org/mybatis-3/configuration.html 存储介质 Redis Java-Driver Jedis 连接池:Jedis的连接池设计基于 Apache Co

Spring mvc Interceptor 解决Session超时配置流程

最近公司内部框架中对Session超时这一功能未实现,由于采用iframe结构,Session超时后,当点击左侧系统菜单时,会在iframe的右侧再次弹出登陆框. 该问题是由于没有设置拦截器造成. 添加拦截器思路:当Session超时后,用户点击menu时,需要用Interceptor进行前项拦截,并判断此时session中是否还存在用户信息,如果不存在,将其指定登陆主页面. 如下代码: 1)首先在applicationContext-mvc.xml中加入mvc:interceptor标签. <

webix+springmvc session超时跳转登录页面

2016-10-30 13:11:56 引言 最近做项目,发现ajax请求不能在服务器中直接重定向到登录页面.查了些资料发现jquery的ajax请求有人给出了方法.但是webix的ajax请求和jquery的有些区别.这里模仿jquery的处理方式实现webix的ajax请求session超时跳转. 具体的做法: 1.查看webix.js源码发现webix.ajax只有请求前的监听函数 "onBeforeAjax", 要做到获取返回状态跳转登录页面必须要有个返回的监听函数,但是源码没