Session destory error
-
hi, i have created a member log in system which will change a page which is included on the homepage.... Ok, now when i log out it destroys the session fine but then i get this error "Notice: Undefined index: logged in ttab.php on line 4", how do i get rid of the error because on other pages it seems to go away ... Code for file which displays depending on session ... (ttab.php)
<html><style>div{font-family:Arial;}</style><body>
<?php
session_start();
if (!($_SESSION['logged']== true))
{
echo"<a href='memlogin.php?msg=0' id='flink'><div>Register/Log In</div></a>";
}else{
$name = $_SESSION['user'];
echo"Welcome $name,  <a href='account.php' id='flink'>Account Options</a> | <a href='ref/logout.php'id='flink'>Log Out</a>";
}
?>
</body></html>Process that the log out does ... (logout.php)
//Logout process
session_start();
session_destroy();
header("location: ../index.php"); -
hi, i have created a member log in system which will change a page which is included on the homepage.... Ok, now when i log out it destroys the session fine but then i get this error "Notice: Undefined index: logged in ttab.php on line 4", how do i get rid of the error because on other pages it seems to go away ... Code for file which displays depending on session ... (ttab.php)
<html><style>div{font-family:Arial;}</style><body>
<?php
session_start();
if (!($_SESSION['logged']== true))
{
echo"<a href='memlogin.php?msg=0' id='flink'><div>Register/Log In</div></a>";
}else{
$name = $_SESSION['user'];
echo"Welcome $name,  <a href='account.php' id='flink'>Account Options</a> | <a href='ref/logout.php'id='flink'>Log Out</a>";
}
?>
</body></html>Process that the log out does ... (logout.php)
//Logout process
session_start();
session_destroy();
header("location: ../index.php");The "undefined index" message is telling you that there is no value with the key 'logged' in
$_SESSION
. Try changing your test to this:if (!(isset($_SESSION['logged']) && $_SESSION['logged']== true))
The
isset
call will short-circuit the test if the 'logged' key is not found.