I have a websi开发者_JAVA技巧te 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?
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
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.
精彩评论