Home  >  Article  >  Backend Development  >  PHP timeout function to verify whether the user is logged in_PHP tutorial

PHP timeout function to verify whether the user is logged in_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:39937browse

Through the action time, if the action time times out, it will be kicked out! Using mktime is a good time calculation function
that can easily calculate the time difference. The smallest unit is seconds.

Function

function user_mktime($onlinetime){
$new_time = mktime();
echo $new_time-$onlinetime;
if($new_time-$onlinetime > 100){
echo "Login timeout";
session_destroy();
}else{
$_SESSION[times]=mktime() ;
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486201.htmlTechArticleThrough the action time, if the action time times out, it will be kicked out! Using mktime is a good time calculation function that can easily calculate the time difference. The smallest unit is seconds. Function ?php function us...
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