I want to know is there any option/work sround for $_SERVER['HTTP_REFERER']. Because 'HTTP_REFERER' can not be trusted. Then What is other way to know that from which url the request has came from?.
Here is the situation - http:// abc.com/one.htmlwill have an iframe having src=http:// xyz.com/giv.php?param=1. How giv.php on xyz.com will know that request is coming from http:// abc.com/one.html?
This looks like it might be an X-Y problem.
If X is
How can I stop unauthorized websites framing my content and presenting it to their unsuspecting users?
Then the referer is "good enough".
For the referer to be forged, the user has to participate. The unauthorised website can't tell the user's browser to send a false referer.
Sorry, there is no other way. Welcome to the Internet
If you really want trust, then:
Even then, the token can be leaked by the user (either intentionally or through malware installed on their system).