1

我正在尝试设置一个 cookie 并使用 header redirect 。但 cookie 没有设置。我试过了print_r($_COOKIE)。所以,我确定 cookie 没有设置在那个地方?

setcookie("re",$re);

header('Location: ' . $_SERVER['HTTP_REFERER']);
4

1 回答 1

2

您需要设置我订购的路径以使其在所有域中可用...

根据文件

The path on the server in which the cookie will be available on. 
If set to '/', the cookie will be available within the entire domain. 
If set to '/foo/', the cookie will only be available within the /foo/ 
 directory and all sub-directories such as /foo/bar/ of domain. 
The default value is the current directory that the cookie is being set in. 

尝试这个

 <?php
  setcookie("re",$re,0,'/');
  header('Location: ' . $_SERVER['HTTP_REFERER']);
?>

注意:推荐人应该来自您的域

于 2013-04-11T11:59:52.700 回答