I have a website where I click on a link and am redirected to another website. Is there a way, the other website (www.otherwebsite.com) can determine accurately that the request has been sent from my website www.mywebsite.com?
views:
25answers:
3
+1
A:
what language?
with javascript you can use : document.referrer with php you can use : $_SERVER['HTTP_REFERER']
however, there is NO method in any language that is 100% accurate, do to the ability to spoof headers.
Crayon Violent
2010-08-17 22:42:17
Thanks for reminding me about headers being spoofed.
Anonymous
2010-08-17 23:04:17
+3
A:
Yes, using the HTTP header called "Referer" (no, that is not a spelling mistake, that is actually the name of the header).
For instance, in PHP you would do this:
<?php echo "You came from this site: <b>".htmlspecialchars($_SERVER['HTTP_REFERER'])."</b>";
The same code in JavaScript:
document.write("You came from this site: <b>"+document.referrer+"</b>");
This could output:
You came from this site: http://www.mywebsite.com/index.html
Frxstrem
2010-08-17 22:42:37
Strictly speaking, it *is* a spelling mistake, but it's *their mistake*, not yours =) +1
David Thomas
2010-08-17 22:48:17