Denoteone
Denoteone

Reputation: 4055

Get Referrer Page without HTTP_REFERER

Is it possible to get the referrer page if $_SERVER['HTTP_REFERER'] is not turned on and you dont have access to the php.ini file?

I used print_r($_SERVER) and saw nothing about HTTP_REFERER in the echoed data.

Below is my script to get the referrer site info but now I need to use JavaScript but am not sure how to work it in:

<? 
    //ini_set("display_errors","2");
    //ERROR_REPORTING(E_ALL);
    $last_page = GetHostByName($_SERVER['HTTP_REFERER']);

    if(strpos($last_page,"fall2011")) {
        echo '<li><a href="'. $last_page  .'" class="navigation-link">Fall 2011</a></li>';
    } else {
        echo $last_page;
    }    
?>

Upvotes: 1

Views: 3024

Answers (1)

BalusC
BalusC

Reputation: 1109132

That's not possible.

Best what you could do is to throw in some JavaScript.

var referrer = document.referrer;

If you need this in the PHP side (and thus the requirement can't be accomplished by JS alone), then you need to let JS send it by Ajax, or add it as a hidden input field of a form, or append as a query string to internal page links. The hard part is associating the right referrer with the requested page in the server side.

Upvotes: 2

Related Questions