PHP会话错误
问题描述:
I am using following session variables on 3 pages:-
On Login page,
$_SESSION['login']=1;
On Logout page,
unset($_SESSION['login']);
On Home page,
if(!isset($_SESSION['login']))
{
header("location: index.php");
exit();
}
My homepage is not redirecting to the index.php after vising Logout page.
我在3个页面上使用以下会话变量: - p>
登录时 page, p>
$ _ SESSION ['login'] = 1;
code> pre>
On Logout页面, p >
unset($ _ SESSION ['login']);
code> pre>
在主页上, p>
\ n
if(!isset($ _ SESSION ['login']))
{
header(“location:index.php”);
exit();
}
code> pre>
在访问Logout页面后,我的主页没有重定向到index.php。 p>
div>
答
Did you call session_start()
at the top of the Logout page?