Cookie不能在不同的网页上使用 [英] Cookies not working on different pages

查看:149
本文介绍了Cookie不能在不同的网页上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定我有一个cookie集,我可以清楚地看到,如果我去的私人数据在Firefox ...确定,所以当我回复它在某个目录中的一个页面,它工作,(www.example.com/ dir),但是在网站的索引页(www.example.com)上,它不回显,它说cookie没有设置。是的,我有cookie启用,是我尝试清除缓存和所有。有任何想法吗? PHP btw

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?

setcookie()的PHP手册,强调我的:

From the PHP manual on setcookie(), emphasis mine:


路径

Cookie将在其中使用的服务器上的路径上。如果设置为/,则Cookie将在整个域中可用。如果设置为/ foo /,那么cookie只能在/ foo /目录和所有子目录(如/ foo / bar / of domain)中可用。 默认值是设置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天全站免登陆