Skip to content

Commit

Permalink
[HttpFoundation] fixed empty domain= in Cookie::__toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 20, 2013
1 parent bf870e8 commit cdf501e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __toString()
$str .= '; path='.$this->path;
}

if (null !== $this->getDomain()) {
if ($this->getDomain()) {
$str .= '; domain='.$this->getDomain();
}

Expand Down
5 changes: 3 additions & 2 deletions Tests/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ public function testCookieIsCleared()
public function testToString()
{
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);

$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');

$cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com');

$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');

$cookie = new Cookie('foo', 'bar', 0, '/', '');
$this->assertEquals('foo=bar; httponly', $cookie->__toString());
}
}

0 comments on commit cdf501e

Please sign in to comment.