Home > Backend Development > PHP Tutorial > PHP自定义函数收代码_PHP

PHP自定义函数收代码_PHP

WBOY
Release: 2016-06-01 12:18:02
Original
748 people have browsed it
复制代码 代码如下:
#*******************************************
#作用:页面无操作,自动过期函数
#参数:$onlinetime 当前页面最后一次使用时间
#参数:$interval 页面超时时间
#返回:无
#*******************************************
function user_mktime($onlinetime,$interval){
$new_time = mktime();
if($new_time-$onlinetime > $interval){
echo "登录超时!";
session_destroy();
exit();
}else{
$_SESSION[times] = mktime();
}
}
user_mktime($_SESSION[times],3600) //1小时不使用,当前页面自动过期
?>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template