Gajus\Fuss\App::bypassThirdPartyCookie PHP Method

bypassThirdPartyCookie() private method

When third party cookies are not accepted, client need to be redirected to the domain that needs to drop the cookies and then back to the original URL.
See also: https://github.com/gajus/fuss/issues/2
private bypassThirdPartyCookie ( ) : null
return null
    private function bypassThirdPartyCookie()
    {
        if (isset($_GET['gajus']['fuss']['third_party_cookie'])) {
            \http_response_code(302);
            header('Location: ' . $_GET['gajus']['fuss']['third_party_cookie']);
            exit;
        }
        if (session_status() === \PHP_SESSION_ACTIVE && (!isset($_COOKIE[session_name()]) || $_COOKIE[session_name()] !== session_id())) {
            $content_type = null;
            foreach (headers_list() as $header) {
                $header = mb_strtolower($header);
                if (strpos($header, 'content-type:') === 0) {
                    $content_type = $header;
                    break;
                }
            }
            // Use JavaScript only when content-type HTML or unknown.
            if (!$content_type || strpos($content_type, 'text/html') !== false) {
                parse_str($_SERVER['QUERY_STRING'], $query);
                $query['gajus']['fuss']['third_party_cookie'] = $this->getTopUrl();
                $query = http_build_query($query);
                $request_url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
                $request_url .= '://' . $_SERVER['HTTP_HOST'];
                $request_url .= strpos($_SERVER['REQUEST_URI'], '?') === false ? $_SERVER['REQUEST_URI'] : strstr($_SERVER['REQUEST_URI'], '?', true);
                $request_url .= '?' . $query;
                ?>
                <script>
                window.top.location.href = <?php 
                echo json_encode($request_url, \JSON_UNESCAPED_SLASHES);
                ?>
;
                </script>
                <?php 
            }
        }
    }