note 44751 rejected from function.setcookie by betz
| From: | betz@php.net | Date: | Sat, 11 Dec 2004 14:22:25 +0000 |
| Subject: | note 44751 rejected from function.setcookie by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81682@lists.php.net to get a copy of this message | ||
Note Submitter: mr-yellow at mr-yellow dot com
----
I was wrong.
It's not the manual that is wrong.
It's PHP.
It uses specs from years ago. Still uses the Expiry header.
This code:
setcookie("TestCookie", $value, 3600);
Sents:
Set-Cookie: TestCookie=something+from+somewhere; expires=Thu, 01-Jan-70 01:00:00 GMT
Whereas if PHP was correctly coded it should send this:
Set-Cookie: TestCookie=something+from+somewhere; Max-Age=3600
I'd suguest NOT using the inbuilt cookie functions as they are
old and wrong. Instead roll your own cookie function which
sents the Max-Age parameter as "seconds till expiry" as this
fixes all problems described below.
All you need to do to correctly send up-to-date properly
coded cookies is send the following header before the
Content-Type.
Set-Cookie: Name=Value; Max-Age=Secs; Domain=.www.domain.com; Path=/; Secure=1;\n\n
Everything after Name=Value should be optional.
-Ben