[thelist] PHP SetCookie() function

Jon Haworth JHaworth at witanjardine.co.uk
Wed Mar 7 10:28:07 CST 2001

Things that have screwed me up when working with PHP and cookies:

1. You can't have any whitespace between the top of your document and your
header, and that means inside any includes as well.

2. Cookies must be sent before any other headers (and therefore before your
<html> as well).

3. If the user has cookies turned off you're a bit stuck.

The manual at http://www.php.net/manual/en/function.setcookie.php has some
excellent user comments which list ways round these as well as solutions to
problems other people have experienced.

What the hell is a "wonk", anyway? :-)


-----Original Message-----
From: Jay Greenspan [mailto:jay at trans-city.com]
Sent: 07 March 2001 16:09
To: thelist at lists.evolt.org
Subject: Re: [thelist] PHP SetCookie() function

on 3/7/01 10:01 AM, Charles F. Johnson at charles at littlegreenfootballs.com

> (i sent this to the list yesterday, but for some reason it never showed
> apologies if you're seeing it twice...)
> i'm putting together a page on which i'd like to use the PHP SetCookie()
> function. i've done cookies with javascript before but this is the first
> time with PHP, and i seem to recall hearing about a problem of some kind
> with SetCookie(). i did a search of some of my usual php hangouts, but
> couldn't find anything related to this. does anyone know what i'm talking
> about, or have you used SetCookie() without problems? Any input

The problem isn't the PHP function. It just sends out an HTTP header. The
problems, as always, come from the browsers. I think some of the browsers
are very picky about the exact form of the cookie. If memory serves, some of
the arguments are supposed to be optional but actually aren't ... or
something like that.

Any of you browser wonks want to pick this one up?


For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 

'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or


More information about the thelist mailing list