Re: Alternative to HTTP_REFERER?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



By definition: The referer, or HTTP referer, identifies, from the
point of view of an internet webpage or resource, the address of the
webpage (commonly the URL, the more generic URI or the i18n updated
IRI) of the resource which links to it.

More detail at:
http://en.wikipedia.org/wiki/Referer
http://tools.ietf.org/html/rfc2616

So is a redirecting page a referrer or not? I don't know. Had no time
to translate the gibberish.

I experimented a bit with it and the most suitable solution I found
was passing the referring page on with a GET parameter ...

################## A page redirecting to test.php ##################
<?php
$location = (empty($_SERVER["REQUEST_URI"])) ? 'Location: test2.php' :
'Location: test2.php?ref='.urlencode(base64_encode(gzdeflate($_SERVER["REQUEST_URI"],
8)));
header($location);
?>

################## test.php ##################
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Referrer Test Page</title>
<script type="text/javascript">
alert('Referrer ('+(typeof
document.referrer)+'['+document.referrer.length+']):
'+document.referrer);
</script>
</head>
<body>
<h1>Referred page</h1>
<?
$page = ($_GET['ref']) ?
@gzinflate(base64_decode(urldecode($_GET['ref']))) : 'not found';
echo <<<REFERRER
<h2>Referring page: $page</h2>
REFERRER;
?>
</body>
</html>

#####################

A yeti

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux