// Therefore the get parameter defined above should be used until then. // if( isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] == 'iframe' ) {} if ($enableSameSiteFix && AdvancedIframeCookie::isSecure()) { foreach (headers_list() as $value) { if (AdvancedIframeCookie::aiStartsWith($value, "Set-Cookie")) { if (AdvancedIframeCookie::isSameSiteCookie($value, $filterArray)) { if (!AdvancedIframeCookie::aiContains($value, "Secure")) { $value .= '; Secure'; } if (!AdvancedIframeCookie::aiContains($value, "SameSite")) { $value .= '; SameSite=None'; } if (!AdvancedIframeCookie::aiContains($value, "Partitioned")) { $value .= '; Partitioned'; } } // The first cookie replaces all existing ones // https://www.php.net/manual/de/function.header.php -> See replace // All the others are appended if ($first) { header($value); $first = false; } else { header($value, false); } } } if ($debug) { echo 'SameSite cookie fix applied...
'; } } elseif ($debug) { echo 'SameSite cookie fix is not applied...
'; } if ($debug) { echo 'headers list:
'; echo '
';
      print_r(headers_list());
      echo '
'; } } static function isSameSiteCookie($cookie, $filterArray) { foreach ($filterArray as $value) { if ($value === 'ALL' || AdvancedIframeCookie::aiContains($cookie, trim($value) . '=')) { return true; } } return false; } static function aiStartsWith($haystack, $needle) { return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; } static function aiContains($str, $substr) { return strpos($str, $substr) !== false; } /** * Duplicate of AdvancedIframeHelper::isSecure to be able to use this class standalone. */ static function isSecure() { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443; } }