Code Failing To Read Cookie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ankit.kapoor83
Forum Newbie
Posts: 2
Joined: Thu Jun 03, 2010 5:00 am

Code Failing To Read Cookie

Post by ankit.kapoor83 »

Hi,

I am a beginner in php. I am setting the cookies on one page and validating them on the next one. I can see the cookies being set in Firefox's cookie editor but the code fails to read the cookies. Here is whats happening:

I authenticate and set the cookie on
http://localhost/page/public/index.php
After authentication, i am redirecting the user to one folder up i.e.
http://localhost/page/home.php
home.php is where i am trying to read the cookie value but it shows up blank.

The code reads the cookies fine if I move home.php to /page/public/ from its current location (/page/).

Can someone please suggest a remedy for this?

Thanks in Advance,
Ankit
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Code Failing To Read Cookie

Post by markusn00b »

Without seeing the code, one can only guess. However, check out the $path parameter for setcookie()

Mark.
ankit.kapoor83
Forum Newbie
Posts: 2
Joined: Thu Jun 03, 2010 5:00 am

Re: Code Failing To Read Cookie

Post by ankit.kapoor83 »

Thanks.

I had set the path to "/" couple of hours back but it wasnt working. It started working now.

Thanks Anyways :)
Ankit
Post Reply