help!!cookie只能在本页内使用

#1 yrdr

我用了ucenter的接口弄了同步登陆,然后还'url_path_info' => TRUE,结果设置的$_cookie只能在本页面内有效,到了其他页面就没有值了,但是如果将'url_path_info' => FALSE,时又可以,这到底是为什么呢??

2010-09-14 00:41:57

#2 jake

应该是setcookie的作用域问题,你可以尝试将setcookie的第五个参数设置为你的网站的整个域名

http://php.net/manual/en/function.setcookie.php

setcookie("TestCookie", $value, time()+3600, "/", ".example.com", 1);

2010-09-14 08:26:51