Closed RubtsovAV closed 7 years ago
Please, can you tell me the reason to use the expire value as a timestamp ? Cookie expiration value must be in international standard format (02-Dec-2016 07:19:25 GMT)
Because the Cookie class expect expires as unix timestamp.
/**
* Check if the cookie is expired
*
* @return bool
*/
public function isExpired()
{
return $this->getExpires() && time() > $this->getExpires();
}
Also the ArrayCookieJar use a cookie expires as unix timestamp too.
/**
* @inheritdoc
*/
public function removeExpired()
{
$currentTime = time();
$this->cookies = array_filter($this->cookies, function (Cookie $cookie) use ($currentTime) {
return !$cookie->getExpires() || $currentTime < $cookie->getExpires();
});
return $this;
}
And the CookieFile class for http-client-curl to expect it too.
Even SetCookie class sets expire
as a Unix timestamp, but only if the specified by max-age.
if (!$data['expires'] && $data['max_age']) {
$data['expires'] = time() + (int) $data['max_age'];
}
Indeed their are some mistake in the way expires is used, let me think about it, I'm not available atm
Thanks for your contribution and sorry for the delay for merging
In Cookie instance the expires must contain a unix timestamp, but if you use SetCookieString::parse() in the expires was a time string in gmt format. This is PR fix that.