Home >Backend Development >PHP Tutorial >PHP timeout function to verify whether the user is logged in_PHP tutorial
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() ;
}
}
?>