在过去的两周里,我一直致力于在cookie中保存页面ID,然后在其他页面中检索它.
最后我解决了它,但现在我有一些其他问题我想在我的PHP代码中使用这个id(我在cookie中保存并检索它).
我知道javascript是客户端代码,PHP是服务器端代码,但我必须这样做.这个你能帮我吗.
这是我的javascript代码,它工作得很好,我得到了这行“value.favoriteid”的已保存ID
最佳答案
在PHP端读取cookie,用js设置它们是最容易的事情.
Any cookies sent to you from the client will automatically be included
into a $_COOKIE auto-global array if variables_order contains “C”. If
you wish to assign multiple values to a single cookie,just add [] to
the cookie name.
Depending on register_globals,regular PHP variables can be created
from cookies
这里的PHP是一些例子:
PHP
echo $_COOKIE["your cookie name"];
?>
PHP
print_r($_COOKIE);
?>
It’s not recommended to rely on them as this
feature is often turned off for the sake of security.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。