Possible Duplicate:
php/html – http_referer
I want to find which page/script get request to current page/script.
For example
I am on page “index.php”
I click on link that takes me to “about.php”
Now, on “about.php”, I need to find referrer, i.e., “index.php”
I need solution, that works on any OS/Platform (Windows, Linux, Mac OS X)
Thank
Don’t trust
$_SERVER['HTTP_REFERER']: it is a bad solution because it’s not reliable, set by the user agent, possible to modify, and not always set or is set incorrectly.Try setting the current page to a
$_SESSIONitem at the end of each page load, and referencing that as your “last url”. It will work as long as the last url was within your site, otherwise the$_SERVER['HTTP_REFERER']is probably your only way.However, DO NOT trust it, and whatever you do, don’t redirect to it within your site or you may find yourself in an infinite redirect loop.