Skip to content

Commit 495d0e3

Browse files
committed
[HttpFoundation] fixed empty domain= in Cookie::__toString()
1 parent c2bc707 commit 495d0e3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/HttpFoundation/Cookie.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __toString()
9595
$str .= '; path='.$this->path;
9696
}
9797

98-
if (null !== $this->getDomain()) {
98+
if ($this->getDomain()) {
9999
$str .= '; domain='.$this->getDomain();
100100
}
101101

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ public function testCookieIsCleared()
117117
public function testToString()
118118
{
119119
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
120-
121120
$this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie');
122121

123122
$cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com');
124-
125123
$this->assertEquals('foo=deleted; expires=' . gmdate("D, d-M-Y H:i:s T", time()-31536001) . '; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL');
124+
125+
$cookie = new Cookie('foo', 'bar', 0, '/', '');
126+
$this->assertEquals('foo=bar; httponly', $cookie->__toString());
126127
}
127128
}

0 commit comments

Comments
 (0)