浏览代码

[HttpFoundation] domain shouldn't be required

Spec says: "The default value of domain is the host name of the server which generated the cookie response."
Jordi Boggiano 15 年之前
父节点
当前提交
6142700881
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      src/Symfony/Components/HttpFoundation/HeaderBag.php

+ 3 - 5
src/Symfony/Components/HttpFoundation/HeaderBag.php

@@ -192,10 +192,6 @@ class HeaderBag
             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;
@@ -211,7 +207,9 @@ class HeaderBag
             $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;