Trouble with COOKIES

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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Trouble with COOKIES

Post by pickle »

Hi all,

I'm having a little trouble with making a COOKIE be applicable over multiple directories. Essentially what I've got is a custom session-making script that relies on cookie data. I need to use that cookie to authenticate over multiple directories. The are all in the same main webapp folder, such that

Main_webapp_folder
|
---> Webapp_one
|
---> Webapp_two

I need to be able to have a cookie set in Webapp_one stay alive for Webapp_two.

When making the cookie, I have tried setting the path for the cookie to "../" and "../../webapp", as well as setting the domain to ".mydomain.com". None of this seems to be working though. BTW - I'm on a Linux server. Thanks folks.

UPDATE: Here's the exact call I'm using (except the domain of course)

Code: Select all

setcookie("sid",$cookieInfo,(SESSION_TIMEOUT * 60),"/",".mydomain.com");
//SESSION_TIMEOUT is a global variable set to 20
UPDATE 2:

I think I may have narrowed down the problem. Here are two setcookie calls:

Code: Select all

setcookie("sid",$cookieInfo,(SESSION_TIMEOUT * 60),"/",".mydomain.com");
setcookie("sid",$cookieInfo);
The first one fails, the second one works. WHAT THE HELL IS GOING ON!!!

(Needless to say this is starting to get irksome.)
Post Reply