Cookie 在不同页面上不起作用 [英] Cookies not working on different pages

查看:53
本文介绍了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 在不同页面上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆