Forum Moderators: coopster
can someone tell me why unset is not working please:
code on header.php is
----------------------------------------------
<?php
if ($_SESSION['auth']='true') {
echo "set";
$disp="logout";
}
else {
echo "not set";
$disp="Login";
}
?>
<a href="<?php echo $disp;?>.php" class="new2"><?php echo $disp;?></a>
-------------------------------------------------
on logout.php the code is
-------------------------------------------------
<?php session_start();
/*****
logout.php:
This file logs a user out.
/*
Logout script:
This is a very simple script that does the following:
Checks the user is already logged in.
Destroys/unsets all session data.
Redirects the user to their login page.
*/
// Log user out:
unset ($_SESSION['username']);
unset ($_SESSION['auth']);
// Redirect:
header("Location: index.php");
?>
---------------------------------------
So can someone tell me then why when it directs back to header.php the session[username] still prints "set"
Thanks for looking
if ($_SESSION['auth'] == 'true')
Oops. Missed that one. Also, if you want the $_SESSION['auth'] to be boolean, you'd need to leave off the quotes for the value TRUE.
Thinking about it, if $_SESSION['auth'] were boolean, you could just leave off the '== TRUE' altogether and just make it:
if ($_SESSION['auth']){ baze
go back a page and its full of errors such as these.
Notice: Undefined index: log in C:\Inetpub\wwwroot\aa\sell3.php on line 10
Notice: Undefined index: upfile in C:\Inetpub\wwwroot\aa\sell3.php on line 11