View Full Version : Why Header does not work?

06-26-2010, 12:39 AM
I have a problem, but don't know where...
I start session with[this is just a part of all script - $nick and $password are correct]:



$_SESSION['id'] = $id;

$hash = md5($nick.$password.$sess_browser);
$_SESSION['hash'] = $hash;
setcookie("hash", "$hash");

Then I brake this session with:

if($_GET['act'] == 'logout') {

After that, My auth.php must redirect me to login page, but it doesn't work...


$host = $_SERVER['HTTP_HOST'];
$link = "http://$host/login.php";

if($_COOKIE['hash'] != $_SESSION['hash']){
header("Location: $link");


Header is not working... Maybe session is not destroyed or it has both empty values and they are equal... How I can solve this??

Thanks in advance :)

06-26-2010, 02:37 AM
How about this thought ...

You have this:
if($_COOKIE['hash'] != $_SESSION['hash']){
header("Location: $link");

If you think about it, both the cookie and the session are gone ...
so they DO equal each other?

Perhaps you only need to check for the SESSION to be set ...

// user is still logged in ... do nothing
} else {
// user is no longer logged in.
header("Location: $link");

06-27-2010, 01:36 AM
if(!isset($_COOKIE['hash']) || !isset($_SESSION['hash']) || $_COOKIE['hash'] != $_SESSION['hash']{
header("Location: $link");

And of course, could just be a silly white space or something messing up the header.

06-30-2010, 11:05 AM
If you are sending it to services like hotmail or yahoo they may filter it for spam if the headers don't meet rfc standards.
To send a from field, either use the email address or the proper format such as
$headers = "From: \"Your Name Here\" <you@yoursite.com>";

To add more than one header make sure to separate each one with \r\n and not just a \n.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum