PHP custom function collection code

  • 2020-03-31 21:01:13
  • OfStack

 
<?php 
#******************************************* 
# role : Page no action, automatic expiration function  
# parameter :$onlinetime  The last time the current page was used  
# parameter :$interval  Page timeout  
# return : There is no  
#******************************************* 
function user_mktime($onlinetime,$interval){ 
$new_time = mktime(); 
if($new_time-$onlinetime > $interval){ 
echo " Login timeout! "; 
session_destroy(); 
exit(); 
}else{ 
$_SESSION[times] = mktime(); 
} 
} 
user_mktime($_SESSION[times],3600) //If not used for 1 hour, the current page will automatically expire
?> 

Related articles: