【发布时间】:2014-10-25 06:15:49
【问题描述】:
我使用wordpress,我设置cookie的目的是为了在Chrome和其他浏览器上完美运行,但在Firefox中不行,当我在firefox中打印$_COOKIE时它是空的,但实际上包含 cookie,相同的代码在其他浏览器上打印 cookie,当然 cookie 在 Firefox firebug 中可见,但在 $_COOKIE 上不可见。
谁能告诉我如何访问它们?什么是限制?如何解决? 我的代码是这样的
if(isset($_GET['attr'])){
$inTwoMonths = 60 * 60 * 24 * 60 + time();
$attr = $_GET['attr'];
setcookie('attr', $attr , $inTwoMonths,'/');
print_r($_COOKIE);
}
【问题讨论】:
-
Common Pitfalls: Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires.
标签: php wordpress cookies mozilla