Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/Cookie/CookieInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface CookieInterface
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
* @see https://tools.ietf.org/html/rfc7231#section-7.1.1.2
*/
public const EXPIRES_FORMAT = 'D, d-M-Y H:i:s T';
public const EXPIRES_FORMAT = DATE_RFC7231;

/**
* Returns a unique identifier for the cookie consisting
Expand Down
8 changes: 4 additions & 4 deletions tests/system/Cookie/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ public function testExpirationTime(): void
// expires => 0
$cookie = new Cookie('test', 'value');
$this->assertSame(0, $cookie->getExpiresTimestamp());
$this->assertSame('Thu, 01-Jan-1970 00:00:00 GMT', $cookie->getExpiresString());
$this->assertSame('Thu, 01 Jan 1970 00:00:00 GMT', $cookie->getExpiresString());
$this->assertTrue($cookie->isExpired());
$this->assertSame(0, $cookie->getMaxAge());

$date = new DateTimeImmutable('2021-01-10 00:00:00 GMT', new DateTimeZone('UTC'));
$cookie = new Cookie('test', 'value', ['expires' => $date]);
$this->assertSame((int) $date->format('U'), $cookie->getExpiresTimestamp());
$this->assertSame('Sun, 10-Jan-2021 00:00:00 GMT', $cookie->getExpiresString());
$this->assertSame('Sun, 10 Jan 2021 00:00:00 GMT', $cookie->getExpiresString());
}

/**
Expand Down Expand Up @@ -272,15 +272,15 @@ public function testStringCastingOfCookies(): void
$a->toHeaderString(),
);
$this->assertSame(
"cookie=monster; Expires=Sun, 14-Feb-2021 00:00:00 GMT; Max-Age={$max}; Path=/web; Domain=localhost; HttpOnly; SameSite=Lax",
"cookie=monster; Expires=Sun, 14 Feb 2021 00:00:00 GMT; Max-Age={$max}; Path=/web; Domain=localhost; HttpOnly; SameSite=Lax",
(string) $b,
);
$this->assertSame(
'cookie=lover; Path=/; Secure; SameSite=Strict',
(string) $c,
);
$this->assertSame(
'cookie=deleted; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/; HttpOnly; SameSite=Lax',
'cookie=deleted; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/; HttpOnly; SameSite=Lax',
(string) $d,
);

Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/changelogs/v4.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Message Changes
Changes
*******

- **Cookie:** The ``CookieInterface::EXPIRES_FORMAT`` has been changed to ``D, d M Y H:i:s \G\M\T`` to follow the recommended format in RFC 7231.

************
Deprecations
************
Expand Down
Loading