Page 1 of 1

http_referer question

Posted: Mon Dec 26, 2005 7:00 pm
by jaymoore_299
I made a page to record the http_referer of all visitors to a webpage. It seems to work for most cases, but when I try it myself I find that the value is not filled in for my own visits.

Is this value only filled in when I come to that page through a link from a different page? What other cases would this be left empty?

Re: http_referer question

Posted: Mon Dec 26, 2005 7:39 pm
by foobar
jaymoore_299 wrote: Is this value only filled in when I come to that page through a link from a different page?
Yes, that's the whole point of an HTTP_REFERER. It holds the url of the page that referred you to the one you're on.

On a side note, using HTTP_REFERERS for anything else than non-crucial statistics (read: fun facts) isn't a good idea. The HTTP_REFERER, as the name states, is sent int he HTTP request, which can be easily altered to show a different url. What the browser can do, you can do to.

Posted: Mon Dec 26, 2005 11:59 pm
by m3mn0n
Yep. Altered, or not even sent at all.

So make sure to add an if statement to check if it does exist, because you may have an error if you simply refer to it.

Posted: Tue Dec 27, 2005 12:15 am
by blacksnday
this is part of what i use to track users on my site

Code: Select all

//whats their IP
  $host = $_SERVER['REMOTE_ADDR'];
  //where did they come from
  $uri = $_SERVER['HTTP_REFERER'];
  //what page are they requesting
  $page = $_SERVER['REQUEST_URI'];
  //what browser agent are they using
  $browser = $_SERVER['HTTP_USER_AGENT'];

   if ( $host == 'my.ip.here' )
   { 
      //so i dont include myself in the stats
     //only works if IP stays the same
     }else{
insert stats to db here
}
So it will tell me initially who referred them, then once on site
it shows what page they are on and what page they were previously on.

Posted: Tue Dec 27, 2005 2:21 am
by m3mn0n
User agent is just as unreliable as Referer

Posted: Tue Dec 27, 2005 2:40 am
by blacksnday
Sami wrote:User agent is just as unreliable as Referer
for my stats purposes it doesnt matter.

if i needed to control security, then obvisiouly that route
would not be used.

Posted: Tue Dec 27, 2005 10:29 am
by m3mn0n
Agreed.

Posted: Tue Dec 27, 2005 11:07 am
by foobar
blacksnday wrote:
Sami wrote:User agent is just as unreliable as Referer
for my stats purposes it doesnt matter.

if i needed to control security, then obvisiouly that route
would not be used.
As I said, as long as you don't use HTTP data from the client for anything but fun-facts, you're fine.

Err...what was it you wanted to know? :oops: