When developing a web program, we sometimes need to get the page from which the user is connected, and the referer is used. It is an http protocol, so any language that can develop web programs can be implemented, for example, request. getHeader ("referer") in jsp ")
When developing a web program, we sometimes need to get the page from which the user is connected, and the referer is used.
It is an http protocol, so any language that can develop web programs can be implemented. for example, in jsp:
Request. getHeader ('referer ');
Php is $ _ SERVER ['http _ referer']. I will not give examples of other languages ).
What can it do? Here are two examples:
1. prevent unauthorized connection. for example, I am a software download website. on the download page, I first use a referer to determine whether the previous page is my own website. if not, I will clarify that someone has stolen your connection.
2. for the security of e-commerce websites, I use referer on the pages that submit important information such as credit cards to determine whether the previous page is my own website. if not, it may be a form written by hackers, to skip the javascript verification in your previous page.
Considerations for applying referer:
If I directly input a page with a referer in the browser, the return value is null (jsp). That is to say, the referer will only have content when it is connected from other pages.
I did an experiment. for example, if my referercode is in a.jsp, the webpage is B .htm, and c.htm is a page with iframe. it embeds a. jsp in iframe. Bytes