Forum Moderators: coopster

Message Too Old, No Replies

Cookie problems.

         

j4mes

10:16 am on May 30, 2004 (gmt 0)

10+ Year Member



Can anyone explain why this:

<?
setcookie("something", whatever, time()+36000, "/folder/", ".mydomain.com", 0);
?>

fails to save to my hard drive (session cookie), whereas

<?
setcookie("something", whatever, time()+36000);
?>

does?

Is this an error in my syntax or a browser issue (tested IE5.5/6.0), or is this just how it works?

Thanks.

Birdman

11:41 am on May 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

The only thing I see wrong is that the value(whatever) should be surrounded by quotes. Otherwise, it looks correct.

Birdman

j4mes

11:53 am on May 30, 2004 (gmt 0)

10+ Year Member



Hi Birdman,

I added quotes to the value on my testing page, but the problem still persists; the former still fails to store itself on my hard drive.

I really can't fathom why this should be.

corz

12:41 pm on May 30, 2004 (gmt 0)

10+ Year Member


setting a cookie domain can be problematic.

;o)
(or

j4mes

1:51 pm on May 30, 2004 (gmt 0)

10+ Year Member



:P tell me about it!

palmer

2:17 pm on May 30, 2004 (gmt 0)

10+ Year Member



Hey j4mes
I think there might be 2 errors.
1. The "/folder" are you looking in that directory
2. ".mydomain.com" should there be a period in the prefix?

just wondering if that could help?

palmer

j4mes

4:25 pm on May 30, 2004 (gmt 0)

10+ Year Member



Hi palmer (and welcome to WebmasterWorld)

I don't think these are a problem, since (1) It shouldn't matter what folder I'm in because cookies are only folder-specific if I want them to be, and (2) .mydomain.com is a standard, and means that the cookie applies to all subdomains of mydomain.com.

I'll look into #1 though, any suggestions of errors are a help!

-- James.

isitreal

9:19 pm on May 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think the path is the problem, the default is not your domain at the root, but the folder in which the cookie is created, so if you set path to / it would be set for your domain, then you can leave domain itself blank, I think the domain is only for when you are in a subdomain or something when you set the cookie, and want to make sure the cookie applies to the overall domain, at least as I understand it.

If you want the cookie to only apply in the folder, leave the folder blank.