diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 7d0e680177dc..654960aafcbd 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -984,12 +984,12 @@ public function deleteCookie(string $name = '', string $domain = '', string $pat $prefix = $this->cookiePrefix; } - $name = $prefix . $name; + $prefixedName = $prefix . $name; $cookieHasFlag = false; foreach ($this->cookies as &$cookie) { - if ($cookie['name'] === $name) + if ($cookie['name'] === $prefixedName) { if (! empty($domain) && $cookie['domain'] !== $domain) { diff --git a/tests/system/HTTP/ResponseCookieTest.php b/tests/system/HTTP/ResponseCookieTest.php index 70c38e28051c..e64a795c0d0d 100644 --- a/tests/system/HTTP/ResponseCookieTest.php +++ b/tests/system/HTTP/ResponseCookieTest.php @@ -199,7 +199,7 @@ public function testCookieDelete() $response->setCookie(['name' => 'bee', 'value' => 'bop', 'expire' => 1000]); $response->deleteCookie('bee'); $cookie = $response->getCookie('bee'); - $this->assertTrue($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); + $this->assertEquals($cookie['expires'], '', 'Expires should be an empty string'); // delete cookie with wrong prefix? $config->cookiePrefix = 'mine'; @@ -210,7 +210,7 @@ public function testCookieDelete() $this->assertFalse($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); $response->deleteCookie('bee', '', '', 'mine'); $cookie = $response->getCookie('bee'); - $this->assertTrue($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); + $this->assertEquals($cookie['expires'], '', 'Expires should be an empty string'); // delete cookie with wrong domain? $config->cookieDomain = '.mine.com'; @@ -221,7 +221,7 @@ public function testCookieDelete() $this->assertFalse($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); $response->deleteCookie('bee', '.mine.com', '', ''); $cookie = $response->getCookie('bee'); - $this->assertTrue($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); + $this->assertEquals($cookie['expires'], '', 'Expires should be an empty string'); // delete cookie with wrong path? $config->cookiePath = '/whoknowswhere'; @@ -232,7 +232,7 @@ public function testCookieDelete() $this->assertFalse($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); $response->deleteCookie('bee', '', '/whoknowswhere', ''); $cookie = $response->getCookie('bee'); - $this->assertTrue($cookie['expires'] <= time(), $cookie['expires'] . ' should be less than ' . time()); + $this->assertEquals($cookie['expires'], '', 'Expires should be an empty string'); } }