Home >Backend Development >PHP Tutorial >怎么阻止跳过登录直接访问后台

怎么阻止跳过登录直接访问后台

WBOY
WBOYOriginal
2016-06-13 12:26:201554browse

如何阻止跳过登录直接访问后台!

这样写不对吗
------解决思路----------------------
用户登录后,给该用户写入一个唯一的sessionID,比如$_SESSION['uid'],然后进入后台时,先判断$_SESSION['uid']是否存在且不为空
------解决思路----------------------
一般都是将登录后的特征写入SESSION变量里,然后在需要的地方检查这个变量是否存在以此完成对用户访问权限的判断.
------解决思路----------------------
登陆验证成功后

<br />$_SESSION["user_name"]=$this->username;<br />


其他页面
<br />if(!isset($_SESSION['user_name']))<br />{<br />    //跳回登陆页<br />}<br />

Statement:
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