Finding Out Where Users Have Come From In PHP

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 and view it on a test page like this.

if ( isset($_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.

Add new comment

The content of this field is kept private and will not be shown publicly.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
9 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.