Alex Rivera | Logout

Cookies not working on different pages

Asked 2010-01-10T21:44:34.883
16

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

Edit
Report

2 Answers

5

You need to check the path that the cookie is being set.

If it's not '/', there's your answer!

answered 2010-01-10T21:47:39.620
0

Cookies Must Be Set Before Page Output !!! Since cookies are sent by the script to the browser in the HTTP headers, before your page is sent, they must be set before you even send a single line of HTML or any other page output. The moment you send any sort of output, you are signalling the end of the HTTP headers. When that happens, you can no longer set any cookie. If you try, the setcookie() function will return FALSE, and the cookie will not be sent.

answered 2013-05-12T05:55:40.997

Your Answer