-3

I have a question related to finding the source of a request that comes to our site.

I have a PHP file that has a function and it returns a value. I want to call this function by Ajax through other sites that I have (I do not have a problem with this part).

I was wondering it is possible to check (in the PHP file) if the request for calling the PHP file or function comes only through the sites that I have and if it is not from the defined domains, it returns false.

Do we have any functions to check this matter?

I do not need client IP address, I need to know the domain that sends the request to my site and call my Php function. Do we have a mechanism to control this?

I only want my domains B and C are able to call my PHP function which is in my domain A.

Sam M
  • 4,136
  • 4
  • 29
  • 42
sanik
  • 11
  • 2

2 Answers2

1
$_SERVER['HTTP_REFERER']

Most web browsers pass the HTTP_REFERER variable by default, but in many this behaviour can be changed to not show it or to pass something else instead. It cannot be trusted, but it is still useful...

hexYeah
  • 1,040
  • 2
  • 14
  • 24
1

I have found this link that provides a solution for implementing CORS by PHP.

sanik
  • 11
  • 2