<?php
function has_query_string($url) {
    return strpos($url, '?') !== false;
}
// Name and value of the cookie
$cookieAuthName = '__isac';
$authVal = $_COOKIE[$cookieAuthName];

$improUrl = rawurldecode($_GET['url']);
// // Check if the cookie exist and redirect url exist
if (isset($authVal) && isset($improUrl)) {
    // Redirect to the target URL if the cookie exists
    $improUrl .= ((has_query_string($improUrl)) ? "&a=" : "?a=") . $authVal;
    header("Location: " . $improUrl, true);
    http_response_code(302);
} else {
    // If the cookie does not exist or redirect url does not exist, return 500 status
    http_response_code(500);
}
?>