1

Cookie を設定し、ヘッダー リダイレクトを使用しようとしています。ただしクッキーは設定しておりません。私は試しprint_r($_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 に答える