فهرست منبع

[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;