問題描述
好的,我有一個 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 在不同頁面上不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!