PhpCookieReader.php 697 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Stdlib\Cookie;
  7. /**
  8. * PhpCookieReader is an implementation of CookieReaderInterface that reads cookie data from the php $_COOKIE array.
  9. */
  10. class PhpCookieReader implements CookieReaderInterface
  11. {
  12. /**
  13. * Retrieve a value from a cookie.
  14. *
  15. * @param string $name
  16. * @param string|null $default The default value to return if no value could be found for the given $name.
  17. * @return string|null
  18. */
  19. public function getCookie($name, $default = null)
  20. {
  21. return (isset($_COOKIE[$name])) ? $_COOKIE[$name] : $default;
  22. }
  23. }