Alex Rivera | Logout

PHP HTTP Referrer

Asked 2011-03-15T03:04:01.157
9

I have a page which accepts POSTs from a remote site. I would like to detect the domain that these POSTs are coming from. I realize that it can be spoofed but it is better than nothing. I have tried accessing the HTTP_REFERER variable but it just returns null.

The page accepts POSTs from sources like PayPal (instant payment notifications) and other payment gateways.

How can I get the referring call?

Edit
Report

2 Answers

6
$_SERVER['HTTP_REFERER'] 

with a single R, try var_dump($_SERVER) for more info.

answered 2011-03-15T03:06:41.477
2

You are right that the referrer is easy to spoof, however there is a better solution. Read the ipn documentation in which they mention validation mechanisms. Never trust the user.

answered 2011-03-15T03:09:27.927

Your Answer