I want to capture any external referrers, and store them to a session variable so that I can log the info to the database if they should join at any point in the session.
The code I have assigns the server variable to the session variable, but it keeps reseting after each page view, so that the two are always =, I want the session variable to keep the original referrer, and not just the last page.
As a sub-question, I would like a better way to determine if the referrer was external than searching for referrer does not contain my domain, because the search query could contain my domain, and I would want to capture any external referrers.
Here's my code:
if (!strstr($_SERVER['REFERER'], 'mydomain.com')) { //if refferer is external to site
$_SESSION['external_referrer'] = $_SERVER['HTTP_REFERER'];
}
If the referrer is a page on my site, the session variable shouldn't be updated.
Thanks in advance