Home > Backend Development > PHP Tutorial > 登录页面Session的有关问题

登录页面Session的有关问题

WBOY
Release: 2016-06-13 10:33:31
Original
930 people have browsed it

登录页面Session的问题
大家好,我又来了。

我的页面是这样写的:
session_start();
if($_SESSION['Admin'] == '' || $_SESSION['ID'] == ''){
echo '<script>';<br /> echo 'parent.location.href="Login.php";';<br /> echo '</script>';
}
------------------------------------------------------
现在的问题是一打开页面,它就老是提示错误,没有Session['Admin']变量。
虽然页面还是会继续执行,但是出错了感觉总是不好的。
[email protected],大家都有什么好方法吗。

------解决方案--------------------
if(isset($_SESSION['Admin']) && isset($_SESSION['ID'])){
代码.....
}else{
echo '<script>';<br />echo 'parent.location.href="Login.php";';<br />echo '</script>';
exit;
}
------解决方案--------------------
isset判断是否被赋值过,这和js里undefined是一样的道理。

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