How to prevent cross-domain ajax requests?

后端 未结 6 1181
闹比i
闹比i 2020-12-05 16:43

How can I detect if my php script is being called from another domain and the other domain is making illegal use of my script? Is there a way to prevent this too?

<

6条回答
  •  自闭症患者
    2020-12-05 17:23

    A bit like user3491125 proposed, you could set a $_SESSION in the page where the call is made and check it on the page Ajax called if there is for instance $_SESSION['user'] set.

提交回复
热议问题