session怎么配置过期时间

常用的有两种方法:
1. 在主页面中写入下面两句:
HttpSession session=request.getSession(true);
session.setMaxInactiveInterval(3600);//3600秒,注意服务器端的3600秒,而不是客户端的
2. 在项目的web.xml中设置:
<session-config>
<session-timeout>60</session-timeout>
</session-config>
这里的60就是60分钟。
还有一种在服务器端设置的方法,因为不同的服务器配置不同,在这就不说了,以上两个就足够用了。

猜你喜欢

转载自www.cnblogs.com/19322li/p/11114461.html