设置会话的过期时间 [英] set expire time for a session

查看:65
本文介绍了设置会话的过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用会话变量的登录页面.如何设置会话的过期时间?例如:15 分钟不活动后销毁会话.

I have a login page that uses session variables. How can i set an expire time for a session? eg: after 15 minutes of inactivity destroy the session.

我该怎么做?

推荐答案

你必须在你的会话对象中设置一个变量,用它访问的每个页面的时间,并且你将计算所有页面当前时间是否有差异从上次设置的 15 分钟或更长时间开始,如果是这样,您将使会话无效...

You must set a variable in your session object with the time in every page it accesses, and in that all pages you will calculate if the current time have a difference from the last time setted of 15 minutes or more, if so you invalidate the session...

如果没有,您为该变量设置一个新时间..

if not, you set a new time to that variable..

这篇关于设置会话的过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆