config = $config; $this->value['sameSite'] = $config->get('cookie_same_site') ?: self::STRICT; $this->value['expires'] = $config->get('cookie_expires') ?: self::DEFAULT_EXPIRY; $this->value['path'] = $config->get('cookie_path') ?: self::DEFAULT_PATH; $this->value['domain'] = $config->get('cookie_domain') ?: self::DEFAULT_DOMAIN; $this->value['secure'] = $config->get('cookie_secure') !== null ? $config->get('cookie_secure') : ($this->isSecure()); $this->value['httpOnly'] = $config->get('cookie_http_only') !== null ? $config->get('cookie_http_only') : self::DEFAULT_HTTP_ONLY; } /** @return $this */ public function setStrict() { $this->value['sameSite'] = self::STRICT; return $this; } /** @return $this */ public function setLax() { $this->value['sameSite'] = self::LAX; return $this; } /** @return $this */ public function setNone() { $this->value['sameSite'] = self::NONE; return $this; } /** * @param string $key * @return string */ public function getValue($key) { return $this->value[$key]; } /** @return string[] */ public function getValues() { return $this->value; } /** * @param string $key * @param string|int $value * @return $this */ public function setValue($key, $value) { $this->value[$key] = $value; return $this; } /** * Check if is secure (SSL) connection * @return bool */ public function isSecure() { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443; } /** @return string */ public function getSameSite() { return $this->value['sameSite']; } /** @return string */ public function getExpires() { return $this->value['expires']; } /** @return string */ public function getPath() { return $this->value['path']; } /** @return string */ public function getDomain() { return $this->value['domain']; } /** @return string */ public function getSecure() { return $this->value['secure']; } /** @return string */ public function getHttpOnly() { return $this->value['httpOnly']; } /** * * @return $this */ static public function getInstance() { $class = get_called_class(); return \Phacil\Framework\Registry::getAutoInstance((new $class())); } }