我试图获得我在另一个文件中设置的电子邮件cookie的值。对于设置cookie将下面的代码有:饼干不工作在服务器上,虽然在本地工作正常
setcookie('email', $_SESSION['email'], time()+3600*24*30, 'www.example.com');
在另一个文件中,我试图调用这个cookie,我使用,
$email=$_COOKIE["email"];
但它似乎没有将其值设置为$ email变量,但是当我尝试在其他查询中使用$ email的值时,它工作正常。 我把这里的所有代码都放在这里,以免含糊其辞。
`$email=$_COOKIE['email'];`
$result= mysql_query("select firstname from users where email='$email'");
$firstname=mysql_result($result,0);
echo $email;
$result2= mysql_query("select userid from users where email='$email'");
$cus_id=mysql_result($result2,0);
echo $cus_id;
$result3=mysql_query("select count(*) from cart where userid='$cus_id'");
$proInCart=mysql_result($result3,0);
echo $proInCart;
所以$电子邮件& $ cus_id的值不打印,但$ proInCart工作完全正常。有人可以帮助在这种情况下? 还有一件事,它只是不在服务器上工作,在本地,一切都像魅力一样。
已完成。问题在于设置cookie,因为头文件已经在该文件中发送,cookie没有保存。 现在完成了。:) –