-
Notifications
You must be signed in to change notification settings - Fork 7.8k
setcookie has an obsolete expires date format #9200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The recently approved RFC 9110 states:
So while PHP does not comply to the RFC, it shouldn't cause issues. And given that the RFC 850 format is obsolete for a long time, I don't see the urgent need to fix this; i.e. I'd leave it for PHP 8.0 and 8.1 for BC reasons. |
If the format doesn't cause problems regardless of the format then I don't see how BC comes into it, but by the same token if it doesn't cause problems then it's fine to leave as is. It would be nice if PHP used the "preferred" format as stated in the RFC but it seems unlikely the obsolete format will cause any problems for many years to come. |
I was mostly thinking about test expectations (at least some PHPTs in php-src would be affected). |
I agree here, this is not urgent to fix. The date parsing algorithm is explicitly defined in RFC 6265 (“Cookie RFC”), section 5.1.1 and it supports this legacy format (and various other questionable formats).
I agree with that, this is not something to backport into existing releases. I'd like to see this fixed for PHP 8.2, though. Anything compatible with 2011 RFC 6265 will understand both formats and we should not try to attempt compatibility with more than a decade old systems if we're technically in violation of the spec. |
This also affects ext/date's DATE_FORMAT_COOKIE. |
And also the session cookie. Grepping for |
Ugh, indeed, full day-of-week name instead of abbreviation. The correct format is already available as |
Should everywhere that uses (or as we're discussing, should use) the |
Nobody has reported that the current format causes any problems, and until somebody does, I am not in favour of changing this. |
The date format we're talking about has been introduced by RFC 850, which has been obsoleted by RFC 1036 in 1987! Furthermore, the format |
Description
setcookie()
gives an expires date format that is non-standard as per MDN and HTTP RFC 2616 - the latter of which explicitly refers to the format PHP'ssetcookie()
outputs as "obsolete".The following code:
Resulted in this header output:
Set-Cookie | expires-format-test=test; expires=Sat, 30-Jul-2022 05:12:54 GMT; Max-Age=60
But I expected this header output instead:
Set-Cookie | expires-format-test=test; expires=Sat, 30 Jul 2022 05:12:54 GMT; Max-Age=60
PHP Version
PHP 8.0.21
Operating System
No response
The text was updated successfully, but these errors were encountered: