Home > PHP > Finding Out Where Users Have Come From In PHP

Finding Out Where Users Have Come From In PHP

December 12th, 2008 Leave a comment Go to comments

It is sometimes a good idea to find out where users can come from. When PHP is run the $_SERVER superglobal is always available and if the user has clicked on a link and landed on your page then the HTTP_REFERER value will be set. You can retrieve it like this.

if ( isset($_SERVER[ HTTP_REFERER ]) ) {
 echo $_SERVER['HTTP_REFERER'];
}

Of course you might want to do something useful with this. For example, you might want to know what link a user clicked on when they broke your application.

Categories: PHP Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.