I notice that I lose the $_SERVER['HTTP_REFERER'] when I use the Header() redirect method.

Example:

<? 
//page1.php
header('Location: page2.php'); 
?>
<?
// page2.php
echo $_SERVER['HTTP_REFERER'];
?>

The $_SERVER['HTTP_REFERER'] is blank.

Does anyone know if there is a way to use the header() redirect method and still keep/log the referring url?

thanks

    My guess is no, but you could try adding another header() command to set the referrer before doing the redirect:

    if(!empty($_SERVER['HTTP_REFERER']))
    {
       header('Referer: ' . $_SERVER['HTTP_REFERER']);
    }
    header('Location: http://example.com/page2.php');
    exit;
    
      Write a Reply...