我尝试设置Cookie并使用标头重定向。但cookie没有设置。我试过了print_r($_COOKIE)
。那么,我确定cookie没有在那个地方设置?
setcookie("re",$re);
header('Location: ' . $_SERVER['HTTP_REFERER']);
答案 0 :(得分: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']);
?>
注意:引用者应来自您的域名