I need to get the full domain in which the user sent the ajax request to my server, and it should be somewhat secure.
The
$_SERVER['HTTP_REFERER']
Returns blank.
What function should I use?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Some browsers just don’t send referrer data with XHR requests. The referer header is optional and can be forged anyway. So: you can’t.
The Same Origin Policy is likely to give you all the protection you need (although you haven’t been explicit about your usecase so it is hard to say for sure).