[PHP]页面防刷新代码
· 备忘笔记 · 0 comment · 387 Views

[PHP]页面防刷新代码

· 备忘笔记 · 0 comment · 387 Views
<?php
session_start();
$allow_sep = "3600";
if (isset($_SESSION["post_sep"])) {
    if (time() - $_SESSION["post_sep"] < $allow_sep) {
        exit("请不要反复刷新,请{$allow_sep}秒后再来操作。");
    } else {
        $_SESSION["post_sep"] = time();
    }
} else {
    $_SESSION["post_sep"] = time();
}

Tips:可更改$allow_sep修改防刷新秒数!

添加新评论