Jump to content

$_SERVER['HTTP_REFERER']; Problem


dselva

Recommended Posts

Hi,

 

I have used $_SERVER['HTTP_REFERER']; in my web page, to check the referrer site url.

 

It work for some websites, Not for many. ???

 

Even i used $_SERVER to list all the server variables, but not getting HTTP_REFERER variable.

 

So, please kindly help me to resolve this issue.

 

Thanks,

Selvakumar.D

 

Link to comment
https://forums.phpfreaks.com/topic/58360-_serverhttp_referer-problem/
Share on other sites

php.net says:

 

'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

 

Maybe that is the problem?

 

 

Hi All,

 

Thanks for your reply...

 

The following code i am using to track the referrer.

 

<?

/* Javascript Referer Script*/

echo "Javascript Refferer<br>";

 

$JSURL="<script>document.write(document.referrer)</script>";

$JSHOSTADDR=parse_url($JSURL);

$JSRefererURL=$JSHOSTADDR["host"];

echo $JSRefererURL;

 

 

echo "<br><br>------------------<br><br>";

 

 

/* PHP Referer Script*/

echo "PHP Refferer<br>";

 

$URL=$_SERVER['HTTP_REFERER'];

$HOSTADDR=parse_url($URL);

$RefererURL=$HOSTADDR["host"];

echo $RefererURL;

?>

 

When i was using javascript(document.referrer), getting referrer URL.Not in PHP($_SERVER['HTTP_REFERER']).

 

When i parse the Referrer URL, I am not getting HOST address in JavaScript. But getting in PHP.

 

 

Can anyone plz give me solution for this issue.

 

Thanks

Selvakumar.D

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.