【发布时间】:2013-05-21 18:40:21
【问题描述】:
我在 wordpress 网站上设置和读取 cookie 时遇到问题。
这是我正在做的事情:
1.通过js id发送到php
ajax.js
jQuery.post("/wp-content/themes/mytheme/ajax.php", {post_id: post_id}, function(data){
});
ajax.php
setcookie('myids', $_COOKIE['myids'].$_POST['post_id'], time()+3600*24*100, '/');
2.当我在 /wp-content/themes/mytheme/index.php 中读取那个 cookie ( echo $_COOKIE['myids']; )
我得到了我设置的值,这没关系,但是当我尝试在 /wp-content/themes/mytheme/ajax.php 中读取该 cookie 时,我没有得到 cookie。
我做错了什么?
【问题讨论】:
-
你还没有发布你正在做什么(代码方面)来读取 cookie,所以我们不能开始说你在做什么错误。
-
我已更改问题
-
/wp-content/themes/mytheme/ajax.php 看到的
$_COOKIE的内容是什么?