Reputation: 241
To get the right htpp/https + domain name I use $_SERVER['HTTP_REFERER']. It works well in FF but in Chrome I get the error: Undefined index: HTTP_REFERER
I can solve this simple to include next line in the code above by declaring
$_SERVER['HTTP_REFERER'] = '';
But I find it strange that this erros appears in Chrome. Or do I have to declare always $_SERVER[''] at the beginning of the function?
Upvotes: 0
Views: 3714
Reputation: 9265
Just check if it is set. Simply:
if (isset($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
} else {
$referer = '';
}
or $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
Upvotes: 4