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 在不同页面上不起作用


基础教程推荐
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01