Cookies not working on different pages(Cookie 在不同页面上不起作用)
问题描述
好的,我有一个 cookie 集,如果我在 Firefox 中访问私人数据,我可以清楚地看到它……好的,所以当我在某个目录的一页上回显它时,它可以工作,(www.example.com/dir),但在站点(www.example.com)的索引页面上,它不会回显,它说没有设置cookie.是的,我启用了 cookie,是的,我尝试清除缓存等等.有任何想法吗?PHP 顺便说一句
Ok I have a cookie set, and I can clearly see it if I go to private data in Firefox... ok so when I echo it on one page in a certain directory it works, (www.example.com/dir), but on the index page of the site (www.example.com), it wont echo, it says the cookie is not set. Yes I have cookies enabled, yes I tried clearing cache and all that. Any ideas? PHP btw
推荐答案
设置 cookie 时您在哪个目录?
Which directory are you in when the cookie gets set?
来自 PHP 手册 setcookie(),强调我的:
路径
cookie 可用的服务器上的路径.如果设置为/",cookie 将在整个域中可用.如果设置为 '/foo/',则 cookie 将仅在/foo/目录和域的所有子目录(例如/foo/bar/)中可用.默认值是设置 cookie 的当前目录.
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.
这篇关于Cookie 在不同页面上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Cookie 在不同页面上不起作用
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
