Suddenly setcookie is not working in some of my pages

Hello everyone:
Since YESTERDAY I have a big problem with the cookies, username and password is not recognized in dif sites, it is weird because in other parts they are, I was suspecting that may be the remote server did some changes in directives or something but they say they didn’t. After the page of the LOGIN you enter but then you can’t continue because the user name and password is not stored as cookie. Her is the code:
[php] $User= $_POST[‘username’];
if (isset($_POST[‘username’])){
setcookie(“EDAd”, $User, time()+10800);
setcookie(“PEPEd”, $User, time()+10800);
/* expire in 180 minutes
*/
$Pw = crypt(md5($_POST[‘password’]),md5($_POST[‘password’]));

// echo $Pw;
setcookie(“Passa”, $Pw, time()+10800);
echo ‘User:’,$User;
echo ‘A VER cookie:’,$_COOKIE[“EDAd”] ,‘
Username:’,$_POST[‘username’];
echo ‘Cookie pass:’,$_COOKIE[“Passa”],‘
All:’;print_r($_COOKIE) ;
echo ‘A VER con PEPEcookie:’,$_COOKIE[“PEPEd”] ;
// $colname_Recordset1 = “-1”;
// if (isset($_COOKIE[‘EDAd’]))
// {
// $colname_Recordset1 = $_COOKIE[‘EDAd’];
// }
}
else
{ $User= $_COOKIE[“EDAd”] ;
$Pw =$_COOKIE[“Passa”];
if ($User=="") {echo ‘

Session expired

’;die();}
}

[/php]
It has some echo that I included to show the cookies and they don’t appear.
Thanks for any help.
Luis

Certainly it is not the setcookie instruction. I copied to other pages where cookies were working and it worked, they were stored and showed, and it is in the same remote server.
It is very weird.

Rectifying little thing, the cookie can’t be showed in the same page, so I put the echo and print instructions incorrectly in the same page. But anyway, the error exists, they are not showed in next pages, I continue researching without any answer!
Luis

Luis,
Here is a very basic login system using cookies. http://www.phphelp.com/forum/index.php?topic=17878.0 see if that helps.

I think the issue your experiencing has to do with the URL the cookie is saved under.

Sponsor our Newsletter | Privacy Policy | Terms of Service