PHP 防恶意刷新实现代码_PHP教程

php教程评论437 views阅读模式

复制代码 代码如下:

session_start();

$k=$_GET['k'];

$t=$_GET['t'];

$allowTime = 1800;//防刷新时间

$ip = get_client_ip();

$allowT = md5($ip.$k.$t);

if(!isset($_SESSION[$allowT]))

{

$refresh = true;

$_SESSION[$allowT] = time();

}elseif(time() - $_SESSION[$allowT]>$allowTime){

$refresh = true;

$_SESSION[$allowT] = time();

}else{

$refresh = false;

}

?>

企鹅博客
  • 本文由 发表于 2019年9月14日 18:33:51
  • 转载请务必保留本文链接:https://www.qieseo.com/312136.html

发表评论