How can I restrict access to some PHP pages only from pages within my website?

后端 未结 6 956
北海茫月
北海茫月 2020-12-16 05:08

I have in my website a PHP page which retrieves data from my database to be presented in my website. This page is called via AJAX. How can I restrict the access to it only f

6条回答
  •  Happy的楠姐
    2020-12-16 05:50

    This can not really be done if stated as above, you would need to redesign and implement some kind of authentication scheme, but even that can be emulated. The short answer is that if a web browser can access it then anything can access it as long as it pretends to be a browser.

    There are things you could do to make it harder for someone, like verifying HTTP header fields such as Referer and User-Agent, and implementing session verification in the AJAX calls.

提交回复
热议问题