php代码
<?php session_start(); $nowtime = time() ; if (session_is_registered('lasttime')) { $lasttime = $_SESSION['lasttime']; $times = $_SESSION['times'] + 1; $_SESSION['times'] = $times; }else{ $lasttime = $nowtime; $times = 1; $_SESSION['times'] = $times; $_SESSION['lasttime'] = $lasttime; } if (($nowtime - $lasttime)=5){ header(sprintf("Location: %s",'http://127.0.0.1')); exit; } }else{ $times = 0; $_SESSION['lasttime'] = $nowtime; $_SESSION['times'] = $times; } ?>