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
Cookies with a 0 epoch expiry aren't treated as expired #1952
Comments
I've worked around this by avoiding the class CookieJar extends GuzzleHttp\Cookie\CookieJar {
public function setCookie(GuzzleHttp\Cookie\SetCookie $cookie) {
if ($cookie->getExpires() === 0) {
$cookie->setExpires(1);
}
return parent::setCookie($cookie);
}
} |
Is this project still active? |
If you have a proper solution PRs are always welcome. |
As per guzzle#1952 expiry times specified as "Thu, 01 Jan 1970 00:00:00 GMT" should be treated as expired, but they weren't because 0 was implicitly casting to a bool in SetCookie::isExpired().
Ok, I've added a PR to master with the solution I suggested in the description. The PR is against master, but this is a problem in the 5.3 release too - do you want a PR against that branch as well? |
So is the PR I've provided sufficient, do I need to do anything else to progress this? |
Yes both the PR and the bug report are great, sorry for the delay. Patch release will be out in a few days. |
@neerolyte yeah, a PR against 5.3 branch would be nice too. In the meantime I will merge the PR and tag a patch release for 6.x |
Fixed in #2014 |
As per guzzle#1952 expiry times specified as "Thu, 01 Jan 1970 00:00:00 GMT" should be treated as expired, but they weren't because 0 was implicitly casting to a bool in SetCookie::isExpired().
Actual Behavior
What is the actual behavior?
Cookies with an expiry of
Thu, 01 Jan 1970 00:00:00 GMT
are reportingisExpired()
as false.Expected Behavior
What is the behavior you expect?
They should report as expired.
Steps to Reproduce
Run this code:
You'll get:
Possible Solutions
The current check in
SetCookie::isExpired()
is:I believe it should check
getExpires()
for null rather than just implicitly casting it to bool, e.g:The text was updated successfully, but these errors were encountered: