views:

25

answers:

3

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?

+2  A: 

http://en.wikipedia.org/wiki/HTTP_referrer

here you go.

dierre
+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
Thanks for reminding me about headers being spoofed.
Anonymous
+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
Strictly speaking, it *is* a spelling mistake, but it's *their mistake*, not yours =) +1
David Thomas
I wish I could select more than one answer StackOverflow!
Anonymous