Skip to content

Commit

Permalink
[HttpFoundation] domain shouldn't be required
Browse files Browse the repository at this point in the history
Spec says: "The default value of domain is the host name of the server which generated the cookie response."
  • Loading branch information
Seldaek authored and fabpot committed Jul 24, 2010
1 parent 02fe129 commit 6142700
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Symfony/Components/HttpFoundation/HeaderBag.php
Expand Up @@ -192,10 +192,6 @@ public function setCookie($name, $value, $domain = null, $expires = null, $path
return $this->set('Cookie', $cookie);
}

if (!$domain) {
throw new \InvalidArgumentException('The cookie domain cannot be empty');
}

if (null !== $expires) {
if (is_numeric($expires)) {
$expires = (int) $expires;
Expand All @@ -211,7 +207,9 @@ public function setCookie($name, $value, $domain = null, $expires = null, $path
$cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
}

$cookie .= '; domain='.$domain;
if ($domain) {
$cookie .= '; domain='.$domain;
}

if ('/' !== $path) {
$cookie .= '; path='.$path;
Expand Down

0 comments on commit 6142700

Please sign in to comment.