cookie problem - using a cookie for two different folders.

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
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

cookie problem - using a cookie for two different folders.

Post by JKM »

Hi there,

I'm registering a cookie at sub.myhost.com/folder1/index.php and it works great. I tried to use the same cookie for sub.myhost.com/folder2/index.php, but it doesn't work - although when I right click -> show page info -> security -> show cookies (firefox), the cookie I want to read from is listed. So why won't this work, and how can I fix it?

Thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: cookie problem - using a cookie for two different folders.

Post by requinix »

You answered your own question.
JKM wrote:I'm registering a cookie at sub.myhost.com/folder1/index.php and it works great. I tried to use the same cookie for sub.myhost.com/folder2/index.php
If you "register" a cookie for one folder it is only available at that folder and deeper.
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: cookie problem - using a cookie for two different folders.

Post by JKM »

So there isn't a way to register the cookie for two folders or for all folders at sub.myhost.com?

Thanks for your reply!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: cookie problem - using a cookie for two different folders.

Post by requinix »

Yeah, it's possible.

Any reason you can't just set it for /? Why two paths?
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: cookie problem - using a cookie for two different folders.

Post by JKM »

folder1 is IP-restricted with htaccess, but the content (except the admin content) at folder2 should be available for anyone. Could you please tell me how?

Again, thanks a lot!
Post Reply