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) is in jsp, and php is $ _ SERVER [HTTP_REFERER]. I will not give an example for others (in fact, when developing web programs, we sometimes need to get the page from which the user is connected, which uses referer.
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, it indicates 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 javascript verification on your previous page.
Notes for using referer:
If I enter a page with a referer in a browser, the return value is null (jsp). That is to say, the referer will only have content when it comes to the page by clicking the link from another page.
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