Forum Moderators: coopster

Message Too Old, No Replies

Where is $HTTP_REFERER?

Trying to build a simple user tracking script...

         

mipapage

10:33 am on Nov 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey all,

I think that this may be a common problem, but I haven't been able to figure out what 1. is happening or 2. I'm doing wrong.

I can't seem to get the $HTTP_REFERER data (I'm on windows, server on my machine).

I have seen it the odd time while working with other scripts, sometimes it's there if I "print_r($_SERVER);" and then not there if I "print_r($_SERVER[HTTP_REFERER]);".

What's the story?

I'm building a user tracking script, and wouldn't mind having this data...

coopster

12:32 pm on Nov 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



HTTP_REFERER is not always there, so don't count on using the variable. From the Apache FAQ [httpd.apache.org]:

...it is important to understand that...the REFERER header is intrinsically problematic due to the fact that browsers can send an incorrect REFERER, either because they want to circumvent your restriction or simply because they don't send the right thing (or anything at all).

You could always check to see if it is there using the isset [php.net] function.

Similar issue:
[webmasterworld.com...]

mipapage

1:00 pm on Nov 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks coopster, yer a machine in this forum!

I'll use isset for sure. One more thing though, how in the heck does Apache get the referer for their log files then? I guess that 'referer' is the same 'referer', and therefore can be spoofed etc.?

coopster

4:17 pm on Nov 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>>...a machine...

Shucks (blush), thanks ;)

How do I add browsers and referrers to my logs? [httpd.apache.org]