Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/Cloudflare-CPanel-7.0.1/vendor/guzzlehttp/guzzle/src/Cookie/ |
<?php namespace GuzzleHttp\Cookie; use GuzzleHttp\Utils; /** * Persists cookies in the client session */ class SessionCookieJar extends CookieJar { /** @var string session key */ private $sessionKey; /** * Create a new SessionCookieJar object * * @param string $sessionKey Session key name to store the cookie data in session */ public function __construct($sessionKey) { $this->sessionKey = $sessionKey; $this->load(); } /** * Saves cookies to session when shutting down */ public function __destruct() { $this->save(); } /** * Save cookies to the client session */ public function save() { $json = []; foreach ($this as $cookie) { if ($cookie->getExpires() && !$cookie->getDiscard()) { $json[] = $cookie->toArray(); } } $_SESSION[$this->sessionKey] = json_encode($json); } /** * Load the contents of the client session into the data array */ protected function load() { $cookieJar = isset($_SESSION[$this->sessionKey]) ? $_SESSION[$this->sessionKey] : null; $data = Utils::jsonDecode($cookieJar, true); if (is_array($data)) { foreach ($data as $cookie) { $this->setCookie(new SetCookie($cookie)); } } elseif (strlen($data)) { throw new \RuntimeException("Invalid cookie data"); } } }