I need to check the referer of site visitors and I can't get Perl's HTTP-REFERER to yield any information at all. I've even copied and pasted code from perl.com which lists all the $ENV variables and their contents. Everything seems to work ok but still HTTP-REFERER reveals nothing.
I know that the referer should have some content because I've tried it with clicks from search engine listings and the referers appear in the log. I just can't get hold of the data in HTTP-REFERER.
Another script that loops through and prints all the $ENV variables and their contents doesn't even list HTTP-REFERER.
Any help would be appreciated.
PsychoTekk:
yup. I had no doubt about the perl.com scripts. But it isn't a browser problem. It's a serverside problem. The perl script runs on the server and it's there where I can't get hold of the referer.
chris_f:
no. I know not to expect a referer when going straight from my browser :) That's why I've been testing from search engine listings. Also, in case of a cache somewhere down the line (and there shouldn't be one with cgi scripts), I've left the script in place so that people searching the engines and clicking from there are actually testing it for me.
My script logs their user-agents and referers. I'm getting their user-agents ok but not their referers. It's simply empty - or in view of the $ENV loop that I tried at one point, the HTTP-REFERER variable doesn't even exist in the $ENV array.
So I've come up with a possible solution which is to abandon Perl for this script and do it in PHP instead. All I have to do now is find out how to access the referer in PHP :)
Many thanks for taking the time to help.
If PhilC is clicking on his own machine with a firewall running, this could be the effect of the firewall removing the information, thus his page shows no referrer. The code may be running perfectly and converting to PHP may make no difference. Worth checking before he goes to the trouble.
It seems to me that the problem is on the server but I've no idea what's wrong. I'm taking steps to try to find out what's wrong but I'm not optimistic of a positive result. It would probably be better if I take the question to an Apache forum, I think.
Incidentally, gcx, I'm testing by clicking from search engine listings so the referer is passed - it appears in the log file. Also, I'm recording information in a file (as a test) when other people arrive from search engines, so any system that I am using doesn't enter into it. The file captures some info but not the referer.
Since HTTP_REFERER doesn't appear in the list of environment variables using both Perl and PHP3 loops, it must be a server config problem.
Thanks to all for trying to solve it for me :)