If you read the original cookie spec, written by Netscape, the cookie is set
based on the preceding . (dot).

So, if you set a cookie at www.domain.com (using the 5th parameter of
setcookie), you can read it ONLY from www.domain.com.  If you set it at
.domain.com, as long as "dot domain dot com" is in the domain being used, it
will work.  The issue that is getting you is that if you set it for .domain
(According to the original Netscape Spec), then domain.com DOES NOT MATCH,
as domain.com does not have the initial dot.

So, my guess is you are trying to write your cookie from domain.com with
code that says "write this for dot domain dot com" (.domain.com), as in your
example code.  Since Netscape 4 and before follow the spec, they will not
write the cookie, as you are trying to write it to a different domain than
is setting it.  (Those versions will also not read it.)

The solution??

Leave your code the way is it, making sure that $dn never contains anything
but the "domain dot com" (Only one dot).  That will mean the cookie can be
written and read from any domain containing .domain.com (dot domain dot
com), such as you.domain.com, www.domain.com, anyCname_you_want.domain.com,
etc.  Then, make sure your site NEVER loads without the www. (or something
dot domain).

Kind of a pain, but since newer browsers aren't sticking to that original
spec (not sure I.E. ever did), the issue is going away with time.

HTH,

Peter Janett

New Media One Web Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New Upgrades Are Now Live!!!
Windows 2000 accounts - Cold Fusion 5.0 and Imail 7.1
Sun Solaris (UNIX) accounts - PHP 4.1.2, mod_perl/1.25,
Stronghold/3.0 (Apache/1.3.22), MySQL 3.23.43
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PostgreSQL coming soon!

http://www.newmediaone.net
webmaster "at" newmediaone.net
(303)828-9882


----- Original Message -----
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 11, 2003 10:14 PM
Subject: Re: [PHP] setcookie() in various browsers.. 3rd followup.. anyone?


> On Wednesday 12 February 2003 05:44, Chad Day wrote:
> > This is with PHP 4.2 and register_globals off.
> >
> > I am setting cookies and starting a session in the following fashion:
> >
> > setcookie("EMAILADDR", $row[EMAIL], time()+2592000, '/', ".$dn");
> >
> > where $dn = mydomain.com
> >
> > I want the cookies accessible sitewide .. at www.mydomain.com,
> > mydomain.com, forums.mydomain.com, etc.
> >
> > in IE 5.5, IE 6.0, and NS 7.0, it seems this is being accomplished
> > correctly.
> >
> > In NS 4.8 (and 4.7 I assume), the cookies are never even getting set.
Can
> > anyone tell me as to why?  I've been prodding around cookie docs and
trying
> > to find something that works in all browsers, and a lot of people seem
to
> > have the same question..
>
> archives > cookie handling
>
> I'm sure there's some interesting reading to be found.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> Emerson's Law of Contrariness:
> Our chief want in life is somebody who shall make us do what we
> can.  Having found them, we shall then hate them for it.
> */
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to