Hi Everyone,
I've written a short script to kill a session variable that stores the login username of a user. The only trouble is when I try to echo and redirect at some point in the code...here's a quick n' dirty example...
<?
session_start();
if (isset($_SESSION["userID"])){
//echo 'Session already Established';
//echo "<p>You've been here too many times $userID . Thanks!</p>";
unset($_SESSION);
session_destroy();
if (!isset($_SESSION["userID"])){
//echo 'Session Destroyed';
}
}
else{
//echo 'Nothing getting through';
}
header("Location: http://xyz.htm");
?>
Now, if I comment out the echo statements it works grand. However if I leave them in I get a
Warning: Cannot add header information - headers already sent by (output started at /blah/blah...) in /blah/blah/logout.php on line 19
It's confusing, and I don't know enough about PHP to understand that I'm doing something stupid or not. Any ideas anyone?
As far as I'm aware the only other place I'm sending Header information is in the login page....even saying that, why should it make a difference whether echo is commented in or not?