setSameSiteRestriction($sameSiteRestriction); if ($parsedCookie->getSameSiteRestriction() === Cookie::SAME_SITE_RESTRICTION_NONE && !$parsedCookie->isSecureOnly()) { \trigger_error('You may have to enable the \'session.cookie_secure\' directive in the configuration in \'php.ini\' or via the \'ini_set\' function', \E_USER_WARNING); } // save the cookie $parsedCookie->save(); } } } /** * Returns and removes the header with the specified name (and optional value prefix) * * @param string $name the name of the header * @param string $valuePrefix the optional string to match at the beginning of the header's value * @return string|null the header (if found) or `null` */ private static function takeHeaderCookie($name, $valuePrefix = '') { if (empty($name)) { return null; } $nameLength = \strlen($name); $headers = \headers_list(); $first = null; $homonyms = []; foreach ($headers as $header) { if (\strcasecmp(\substr($header, 0, $nameLength + 1), ($name . ':')) === 0) { $headerValue = \trim(\substr($header, $nameLength + 1), "\t "); if ((empty($valuePrefix) || \substr($headerValue, 0, \strlen($valuePrefix)) === $valuePrefix) && $first === null) { $first = $header; } else { $homonyms[] = $header; } } } if ($first !== null) { \header_remove($name); foreach ($homonyms as $homonym) { \header($homonym, false); } } return $first; } }