我的cookies仅在设置的PHP页面上可用,这是正常的吗? [英] My cookies are only available on PHP pages they are set on, is this normal?
问题描述
我无法从任何网页(而不是其设置的网页)访问Cookie。我在不同的页面上查看 print_r($ _ COOKIE)
,页面之间的唯一通用变量是 $ _ COOKIE ['PHPSESSID']
。
我在本地XAMPP测试服务器上开发。是否有一个设置我应该更改PHP.ini或这是正常的cookie的行为?对我有用[0]丢个板砖[0]引用举报返回列表发新帖高级模式B Color Image Link Quote Code Smilies您需要登录后才可以回帖登录|
$ b
setcookie(user,Dave Schmave,time()+ 60 * 60 * 24 * 120);
任何帮助将非常感谢。感谢
尝试将Cookie路径设置为根:
setcookie(user,Dave Schmave,time()+ 60 * 60 * 24 * 120,'/')
也是在同一个域上?透过HTTPS存取也会影响您的Cookie。
I cannot access cookies from any page other than the page they are set on. I looked at print_r($_COOKIE)
on different pages and the only common variable between pages is the $_COOKIE['PHPSESSID']
.
I am developing on a local XAMPP testing server. Is there a setting I should change on the PHP.ini or is this normal behavior for cookies? Sorry, I'm a little new to this stuff and I was under the impression cookies were accessible site wide.
I am setting cookies like:
setcookie("user", "Dave Schmave", time()+60*60*24*120);
Any help would be greatly appreciated. Thanks
Try setting the cookie path to the root:
setcookie("user", "Dave Schmave", time()+60*60*24*120, '/');
Also is it on the same domain? Accessing via HTTPS will also affect your cookies.
这篇关于我的cookies仅在设置的PHP页面上可用,这是正常的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!