note 44751 added to function.setcookie

From: Date: Sun, 15 Aug 2004 14:05:15 +0000
Subject: note 44751 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-74705@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44751 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44751&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44751&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74705) next »