Skip to content

Commit 9aa26b3

Browse files
bug #28045 [HttpFoundation] Fix Cookie::isCleared (ro0NL)
This PR was merged into the 2.8 branch. Discussion ---------- [HttpFoundation] Fix Cookie::isCleared | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27946 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- d3d7766874 [HttpFoundation] Fix Cookie::isCleared
2 parents 68ce705 + f750415 commit 9aa26b3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Cookie.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ public function isHttpOnly()
183183
*/
184184
public function isCleared()
185185
{
186-
return $this->expire < time();
186+
return 0 !== $this->expire && $this->expire < time();
187187
}
188188
}

Tests/CookieTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ public function testCookieIsCleared()
153153
$cookie = new Cookie('foo', 'bar', time() - 20);
154154

155155
$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');
156+
157+
$cookie = new Cookie('foo', 'bar');
158+
159+
$this->assertFalse($cookie->isCleared());
160+
161+
$cookie = new Cookie('foo', 'bar', 0);
162+
163+
$this->assertFalse($cookie->isCleared());
164+
165+
$cookie = new Cookie('foo', 'bar', -1);
166+
167+
$this->assertFalse($cookie->isCleared());
156168
}
157169

158170
public function testToString()

0 commit comments

Comments
 (0)