note 69015 deleted from function.setcookie by bjori
| From: | bjori@php.net | Date: | Mon, 08 Jan 2007 10:52:32 +0000 |
| Subject: | note 69015 deleted from function.setcookie by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121439@lists.php.net to get a copy of this message | ||
Note Submitter: Lemonrock Editor
----
If you try to call setcookie() before issuing a 302 via a header("Location:..."), the
cookie will not be sent as part of the 302 response. To get the cookie in the header, use the
header() function instead of setcookie(), i.e. header("Set-Cookie: cookiename=cookievalue;
expires=18-Oct-2008 GMT; path=/; domain=.www.domain.com");
Note also that PHP setcookie() formats the date without dashes, which is accepted by major browsers,
but is not in accordance with the Netscape cookie spec, which specifies the date with dashes.