Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the 'referer' header in PHP?

I want the the url of the page from which a request has been made. How can I do that in PHP?

like image 372
Abdulsattar Mohammed Avatar asked Jun 23 '09 07:06

Abdulsattar Mohammed


2 Answers

The refer(r)er can be found in the $_SERVER global variable. Please note that sending the refer(r)er is completely optional and a user-agent can simply decide to not send the refer(r)ing url.

$_SERVER['HTTP_REFERER']
like image 101
Stefan Gehrig Avatar answered Oct 11 '22 18:10

Stefan Gehrig


$_SERVER['HTTP_REFERER']

The documentations are available here here.

like image 44
TFM Avatar answered Oct 11 '22 19:10

TFM