HTTP Referrer and IE7 and IE8

cocacola09 picture cocacola09 · Mar 17, 2010 · Viewed 8.4k times · Source

Hi i've tried the following to find the referrer in MSIE / IE7 and IE8 but its returning blank each time;

PHP:

<?
echo $_SERVER['HTTP_REFERER'];
?>

JAVASCRIPT:

document.write('Thanks for visiting from ' + document.referrer);

Does any know what the issue could be I'm referering using document.location from a page on another domain and work fine with all other browsers minus MSIE.

Any help would be great!

Answer

Pascal MARTIN picture Pascal MARTIN · Mar 17, 2010

The HTTP Referer header is not required by the HTTP Protocol :

  • It is only sent as an information
  • The browser can, or cannot, send it (Which would explain why you're getting it with some browsers, and not getting it with some others)
  • Some firewall / security software could remove it, I suppose, in some situations (I've seen that, some years ago, if I remember correctly)
  • It can be forged easily by the user

Which means that you cannot rely on the Referer for your application : you can use it to provide some additionnal functionnality, but your application must work even if it's not there, or not correct.