Home > php教程 > php手册 > php用session防止恶意刷新页面

php用session防止恶意刷新页面

WBOY
Release: 2016-06-06 19:55:52
Original
1434 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 php中用session防止恶意刷新页面点击数。?php session_start(); $k=$_GET['k']; $t=$_GET['t']; //防刷新时间 $allowTime = 1800; $ip = get_client_ip(); $allowT = md5($ip.$k.$t); if(

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  php中用session防止恶意刷新页面点击数。

  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;

  }

  ?>

  防止别人恶意刷新页面的点击数,所以就考虑增加一个参数来防止这类情况的发生,COOKIE和SESSION可供选择,不过 COOKIE是客户端的,如果人家禁用COOKIE的话,照样可以恶意刷新点击数。还是用SESSION的好,IP+URL参数的MD5值做 SESSION名,我想大家也不好伪造了吧。

php用session防止恶意刷新页面

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template