Home > Backend Development > PHP Tutorial > 新手求助,想写一个防止刷新的功能

新手求助,想写一个防止刷新的功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:08:54
Original
908 people have browsed it

我觉得用session应该可以实现,但是没有倒腾出来

这是我的代码

if(empty($_SESSION['online'])) //访问过			{				if($_SESSION['time']+10<time())//超过10s间隔					$canpost=1;				else $canpost=0;			}			else			{				$_SESSION['online']=1;//记录为访问过				$canpost=1;//允许发表			}
Copy after login


我的想法是,没有访问过的肯定可以直接发,访问过的有一定时间间隔以后也可以发。上面的代码有什么问题么?


回复讨论(解决方案)

逻辑上有问题!

你在 $_SESSION['online'] 不为空的时候,才对 $_SESSION['online'] 赋值

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template