Jump to content

HTTP_REFERER is null


gobob

Recommended Posts

I have a normal HTML link on an html page on one site pointing to a test.php file on another site.

 

I want to get the URL of the refering page using PHP, but have so far been unsuccessful.

 

Both $_SERVER['HTTP_REFERER'] and getenv('HTTP_REFERER') provide null results.

 

Also, phpinfo() does not display the HTTP_REFERER.

 

I can successfully get the remote IP addresses with $_SERVER['REMOTE_ADDR'].

 

JavaScript successfully displays the correct refering URL with:

 

<script language=javascript>document.write(referer);</script>

 

so, apparently, the header information is available.

 

I have tried this with MSIE and Firefox browsers.

 

I have also placed the test.php file on two different servers, but in each case PHP failed to find the refering URL.

 

Any suggestions would be helpful.

Link to comment
https://forums.phpfreaks.com/topic/64711-http_referer-is-null/
Share on other sites

I have tried that.

 

I believe the key is that phpinfo() displays nothing for HTTP_REFERER.

 

In that case I would not expect and PHP variable or function to provide the referer URL.

 

Since I am new at PHP, I have to ask, should PHP display a value for HTTP_REFERER when a .php file is requested by a normal HTML link?  Or am I striving in vain for something that normally does not work?

Link to comment
https://forums.phpfreaks.com/topic/64711-http_referer-is-null/#findComment-322713
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.