PDA

View Full Version : Can't get HTTP_REFERER



springfrog
05-23-2004, 04:58 PM
Whatever code I use I can't get php to give me a HTTP_REFERER. I've tried
$HTTP_SERVER_VARS['HTTP_REFERER']

$_SERVER['HTTP_REFERER']

and other variations but I just get the error:
Notice: Undefined index: HTTP_REFERER

I've checked phpinfo() and the HTTP_REFERER doesn't seem to be mentioned there. Do I need to change my php.ini file or something to be able to get the HTTP_REFERER details?

jalal
05-24-2004, 03:11 AM
There is not always a referer!

If I type into the location bar of my browser 'http://www.mydomain.com' then there is no referer at all.
If I create a page somewhere with a link that I can click on then the referer will be set.

$_SERVER['HTTP_REFERER'] is not always set and your code needs to check for that and deal with it.

HTH

springfrog
05-24-2004, 11:11 AM
Strange - I tried linking from another page yesterday and even using different browsers as well but still had the same error message. Today I try it and it works fine. Thanks for making me try again jalal.