PHP里防止刷新

时间:2021-09-05 17:00:31
PHP里防止刷新比较麻烦些,比如对计数器的防止刷新比较麻烦,不象asp里那样方便,但依然可以用比如下面的方法来实现
<?php
session_start
();
$allow_sep = "30000";
if (isset(
$_SESSION["post_sep"]))
{
  if (
time() - $_SESSION["post_sep"] < $allow_sep)
  {
        exit(
"请不要反复刷新");
}
else
{
     
$_SESSION["post_sep"] = time();
}
}
else
{
  
$_SESSION["post_sep"] = time();
}
?>