How to get the PHP header() function to actually send a referrer

Hi,
I got a problem, with this code:


<?php
  header("Location: http://www.flashninjaclan.com");
  exit;
?>

This obviously does not send a HTTP_REFERRER and it won’t print anything when this code:


$ref = getenv("HTTP_REFERER"); //gets referrer
print "<br>$ref";

But I’ve seen header() functions that go on that landing page and do return a HTTP_REFERRER, what am I doing wrong?

The server can’t set a referer in this case.
You just instruct the users browser to go to the specified location - but the browser doesn’t need to if it doesn’t want to.
If the browser does it’s the browser request to the new location so the server has already been left and the browser is responsible for all headers.

Actually I figured it out. It you go directly to the redirect page, it doesn’t send a referrer, you have to click on a link to go to the redirection page.

Referrer in your case would probably be fine, but don’t you just want to send some kind of token so that you know the request came from one of your own sites?

<?php
  header("Location: http://www.flashninjaclan.com/index.php?state=ok" . time());
  exit;
?>

Actually I figured it out. It you go directly to the redirect page, it doesn’t send a referrer, you have to click on a link to go to the redirection page.

If I had to do it this way I would at least use the html redirect meta tag in the header.

You can’t guarantee that you will receive a referer value. The browser or firewall may be set to override that field (usually by blanking it out). For those with privacy enabled in their browser or firewall you can’t tell where they came from using that field.