Home  >  Article  >  Backend Development  >  求 PHP 设置管理员帐号session的有效期 代码解决方法

求 PHP 设置管理员帐号session的有效期 代码解决方法

WBOY
WBOYOriginal
2016-06-13 13:37:421105browse

求 PHP 设置管理员帐号session的有效期 代码
比如,管理员登录之后,10分钟不刷新页面,就让此session失效,再次请求页面时,需要重新登录。

------解决方案--------------------
用session记录上次登录时间为当前时间。 以当前时间-上次登录时间与10分钟作比较。如果大于10分钟则销毁session。否则更新session为当前时间。
------解决方案--------------------
写cookie
------解决方案--------------------
php session 默认应该是1440s 也就是24 min

你可以从 php.ini 修改。
也可以这么写吧。
session.gc_maxlifetime="600";//这里是有效时间


------解决方案--------------------

探讨

php session 默认应该是1440s 也就是24 min

你可以从 php.ini 修改。
也可以这么写吧。
session.gc_maxlifetime="600";//这里是有效时间
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn