ResponseCookies.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @since 3.5.0
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Http\Cookie;
  15. use Psr\Http\Message\ResponseInterface;
  16. class ResponseCookies extends CookieCollection
  17. {
  18. /**
  19. * Adds the cookies to the response
  20. *
  21. * @param \Psr\Http\Message\ResponseInterface $response Response object.
  22. * @return \Psr\Http\Message\ResponseInterface
  23. */
  24. public function addToResponse(ResponseInterface $response)
  25. {
  26. $header = [];
  27. foreach ($this->cookies as $setCookie) {
  28. $header[] = $setCookie->toHeaderValue();
  29. }
  30. return $response->withAddedHeader('Set-Cookie', $header);
  31. }
  32. }