/** * Belirtilen cookie değerini döndürür * * @param string $name cookie ismi * @return bool */ public function getCookie($name = '') { if (isset(CookieContainer::getCookies()[$name])) { return CookieContainer::getCookies()[$name]; } else { return false; } }
/** * Cookie dosyalarının atanabilmesi için sınıfı hazırlar */ public function __construct() { $this->setCookies(CookieContainer::getCookies()); }
/** * Cookie Atamasını yapar * $name -> cookie adı * $value -> cookie değeri * $expires -> geçerlilik süresi * $path->cookie nin geçerli olacağı alan * $domain->cookie'in geçerli olduğu domain * $sucere->cookie'nin secure değeri * $httpOnly -> cookie'in httpony değeri * * @param string $name * @param string $value * @param int $expires * @param string $path * @param null $domain * @param bool $secure * @param bool $httpOnly * @return $this */ public function set($name = '', $value = '', $expires = 3600, $path = '/', $domain = null, $secure = false, $httpOnly = false) { if (!is_string($name)) { throw new InvalidArgumentException('Cookiler sadece string olarak depolanabilir'); } if (!is_string($value)) { throw new InvalidArgumentException('Cookiler sadece string olarak depolanabilir'); } if ($this->isEncode()) { $value = $this->getEncoder()->encode($value); } $cookie = Generator::make($name, $value, $expires, $path, $domain, $secure, $httpOnly); CookieContainer::addCookie($cookie); return $this; }