Home > Backend Development > PHP Tutorial > Can get what page you came from, the use of referer_PHP tutorial

Can get what page you came from, the use of referer_PHP tutorial

WBOY
Release: 2016-07-13 17:32:06
Original
1077 people have browsed it

When developing web programs, sometimes we need to get the page from which the user is connected. This is where referer is used.

It is an http protocol, so any language that can develop web programs can be implemented, such as jsp (the first choice for SUN enterprise-level applications) is:

request. getHeader("referer");

php(as the current mainstream development language) is $_SERVER[HTTP_REFERER]. I won’t give other examples (actually I don’t know other languages).

Then what can it be used for? Let me give you two examples:

1. To prevent illegal connections. For example, I am a website for downloading software. On the download page, I first use the referer to determine whether the previous page is my own website. If not, it means someone has stolen the connection. your download address.

2. For the security of e-commerce websites, I use referer on the page where I submit important information such as credit card to determine whether the previous page is my own website. If not, it may be a form written by a hacker. Submit, in order to skip the verification of javascript in your previous page.

Notes on using referer:

If I directly enter the page with referer in the browser, the return is null (jsp(the first choice for SUN enterprise applications)), that is to say, the referer will only have content if you click on the link from another page to this page.

I did an experiment. For example, my referer code is in a.jsp(the first choice for SUN enterprise applications), and its previous page is b.htm, c.htm It is a page with an iframe, which embeds a.jsp(the first choice for SUN enterprise-level applications) in the iframe. I enter the address of b.htm in the browser, and then click to connect to c.htm. The displayed result is b.htm. If I directly enter c.htm in the browser, the displayed result is c.htm

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508731.htmlTechArticleWhen developing web programs, sometimes we need to get the page from which the user is connected. This is used referer. It is an http protocol, so any language that can develop web programs can...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template