[PATCH] Addition of setcookie2() to support RFC 2965

php.internals

Ben Ramsey

19 years ago
Here is a patch I am submitting as a recommendation to implement a setcookie2() function to support the Set-Cookie2 response header defined in RFC 2965. RFC 2965 obsoletes the original Netscape cookie specification and RFC 2109. Unfortunately, the only major browser I can find that implements Cookie2 and Set-Cookie2 from the client side is Opera. Nevertheless, the Set-Cookie2 header provides improvements over the original Set-Cookie header: 1) Clients can provide users with more control over what they accept and show them the provided Comment or a link to the CommentURL, allowing the application can tell the user how it is using the specific cookie. 2) Discard and Max-Age provide better control over cookie expiration and deletion. (Expires is not present.) 3) Port provides the ability to specify a list of ports for which the cookie is valid (at the given Domain). There are a few statements in RFC 2965 that this patch does not cover: "When it receives a Cookie header, the origin server SHOULD treat cookies with NAMEs whose prefix is $ specially, as an attribute for the cookie." "User agents that receive in the same response both a Set-Cookie and Set-Cookie2 response header for the same cookie MUST discard the Set-Cookie information and use only the Set-Cookie2 information." (If the user agent obeys this rule, then this could potentially cause a problem setting PHPSESSID with Set-Cookie and setting cookies with setcookie2() in the same response.)
-- Ben Ramsey http://benramsey.com/

Stanislav Malyshev

19 years ago
> Here is a patch I am submitting as a recommendation to implement a > setcookie2() function to support the Set-Cookie2 response header defined > in RFC 2965.
I think setcookie2 can ve useful, but a function with 13 arguments is a monster. Especially that you may not use all of them. Maybe it's better to have them as an array of secondary parameters?
-- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

Ben Ramsey

19 years ago
On 8/25/07 4:58 PM, Stanislav Malyshev wrote:
>> Here is a patch I am submitting as a recommendation to implement a >> setcookie2() function to support the Set-Cookie2 response header >> defined in RFC 2965. > > I think setcookie2 can ve useful, but a function with 13 arguments is a > monster. Especially that you may not use all of them. Maybe it's better > to have them as an array of secondary parameters?
Yep. Sara already suggested this to me, so I'm working on a new patch for this. Thanks!
-- Ben Ramsey http://benramsey.com/