[FAQ] How do I get the address of the referrer?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Q: How do I get the address of the referrer?

A: With the variable $_SERVER['HTTP_REFERER'].  However, two

1. A request might not have a Referer header, in which case
the variable would not be set.  Some browsers do not send
Referer headers, for example, while others can be configured
not to.

'The Refer field MUST NOT be sent if the Request-URI was
obtained from a source that does not have its own URI, such
as input from the user keyboard.'  [HTTP/1.1]

2. A Referer header can be faked.  The information might not
be genuine.

Warning:  As with all input, you should be cautious over the
value of $_SERVER['HTTP_REFERER'].

Note:  The Referer header is misspelt; the word in English
is 'referrer', with four r's.  As the misspelling has made
it into the HTTP specification, it is too late to correct


Site Timeline