多用户上,只请允许一个用户访问某个页面

WBOY
Release: 2016-06-13 13:18:18
Original
1034 people have browsed it

多用户下,只请允许一个用户访问某个页面。
我ajax 来访问A.php页面,但是又会有很多人会调用到这个ajax来访问到这个A.php页面,请问。怎么来保证在某个时间内,只允许某个用户来访问到a.php,也就不充许多个用户来访问一个文件。

------解决方案--------------------
可能性存在,但需求不合理
互联网就是为公众服务的,为何要限定只给个人
------解决方案--------------------
a.php执行一开始检查memcache原子+1,结束时候memcache原子-1.

如果memcache加1返回1,那么说明是第一个用户,可以访问.
如果memcache加1>1,那么不是第一用户,拒绝。
------解决方案--------------------

探讨

引用:

a.php执行一开始检查memcache原子+1,结束时候memcache原子-1.

如果memcache加1返回1,那么说明是第一个用户,可以访问.
如果memcache加1>1,那么不是第一用户,拒绝。


不使用memcache呢,我想过通过读取和写入txt文件里的1和0还完成你的思路,就不知道这读取与写入完成之前会不会有比较大的延迟。

------解决方案--------------------
看看能不能使用生文件的方式,不过那样子应该会比较损硬盘吧。。。对硬盘擦写太频繁了,我自己简单想到的法子而已,别拍砖啊~~~
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!