How can PHP developers ensure cross-browser compatibility when implementing access control based on the referring page?

When implementing access control based on the referring page in PHP, PHP developers can ensure cross-browser compatibility by using the $_SERVER['HTTP_REFERER'] variable to retrieve the referring page URL. They can then compare this URL with a whitelist of allowed referring pages to determine access.

// Check if the referring page is in the whitelist
$allowed_referring_pages = array('http://example.com/page1', 'http://example.com/page2');
$referring_page = $_SERVER['HTTP_REFERER'];

if (in_array($referring_page, $allowed_referring_pages)) {
    // Access granted
    echo "Access granted!";
} else {
    // Access denied
    echo "Access denied!";
}