@@ -40,12 +40,8 @@ public function __construct()
4040 public function collect (Request $ request , Response $ response , \Exception $ exception = null )
4141 {
4242 $ responseHeaders = $ response ->headers ->all ();
43- $ cookies = array ();
4443 foreach ($ response ->headers ->getCookies () as $ cookie ) {
45- $ cookies [] = $ this ->getCookieHeader ($ cookie ->getName (), $ cookie ->getValue (), $ cookie ->getExpiresTime (), $ cookie ->getPath (), $ cookie ->getDomain (), $ cookie ->isSecure (), $ cookie ->isHttpOnly ());
46- }
47- if (count ($ cookies ) > 0 ) {
48- $ responseHeaders ['Set-Cookie ' ] = $ cookies ;
44+ $ responseHeaders ['set-cookie ' ][] = (string ) $ cookie ;
4945 }
5046
5147 // attributes are serialized and as they can be anything, they need to be converted to strings.
@@ -403,41 +399,4 @@ protected function parseController($controller)
403399
404400 return is_string ($ controller ) ? $ controller : 'n/a ' ;
405401 }
406-
407- private function getCookieHeader ($ name , $ value , $ expires , $ path , $ domain , $ secure , $ httponly )
408- {
409- $ cookie = sprintf ('%s=%s ' , $ name , urlencode ($ value ));
410-
411- if (0 !== $ expires ) {
412- if (is_numeric ($ expires )) {
413- $ expires = (int ) $ expires ;
414- } elseif ($ expires instanceof \DateTime) {
415- $ expires = $ expires ->getTimestamp ();
416- } else {
417- $ tmp = strtotime ($ expires );
418- if (false === $ tmp || -1 == $ tmp ) {
419- throw new \InvalidArgumentException (sprintf ('The "expires" cookie parameter is not valid (%s). ' , $ expires ));
420- }
421- $ expires = $ tmp ;
422- }
423-
424- $ cookie .= '; expires= ' .str_replace ('+0000 ' , '' , \DateTime::createFromFormat ('U ' , $ expires , new \DateTimeZone ('GMT ' ))->format ('D, d-M-Y H:i:s T ' ));
425- }
426-
427- if ($ domain ) {
428- $ cookie .= '; domain= ' .$ domain ;
429- }
430-
431- $ cookie .= '; path= ' .$ path ;
432-
433- if ($ secure ) {
434- $ cookie .= '; secure ' ;
435- }
436-
437- if ($ httponly ) {
438- $ cookie .= '; httponly ' ;
439- }
440-
441- return $ cookie ;
442- }
443402}
0 commit comments