开发者

PHP Cookies problem... cookie working on one page but not working on another

开发者 https://www.devze.com 2023-02-13 11:33 出处:网络
Hi can anyone explain this to me: On one page I have: setcookie(cookiename,$cookiedata,time()+(84600*30*24));

Hi can anyone explain this to me:

On one page I have:

setcookie(cookiename,$cookiedata,time()+(84600*30*24));
setcookie(cookiename2,$cookie2data, time()+(84600*30*24));

If on the same page i say:

echo $_COOKIE['cookiename']; 

it works fine....

but if i go to a page which is a few clicks onwards, and say:

echo $_COOKIE['cookiename'];

nothing appears. Why does this happen? is the cookie deleted in some way?

oh and if you try it on the page in between, the same problem occurs.... I'm stumped,

Thank开发者_如何学Cs in advance, Niall


Are the different pages on the same domain? You should also be setting a path, I have found cases when the path was not set to '/' then it would not be accessible by default 'everywhere' on the site even though that would make sense as the default.

Try setting the path of the cookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消