Home > Backend Development > PHP Tutorial > PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial

PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial

WBOY
Release: 2016-07-13 09:44:38
Original
1642 people have browsed it

PHP cannot obtain Referer troubleshooting, referer troubleshooting

Test results:

PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial'Test source: load the page directly
'; echo 'Enter page
'
; echo 'Test source: new window opens
'
; echo 'Enter page
'
;

The code of test_cookie.php is:

<?php

date_default_timezone_set(<span class="str">'Asia/Shanghai'</span>);<span class="rem">//设置默认时区</span>
header(<span class="str">'content-type:text/html; charset=utf8'</span>);<span class="rem">//设置返回头信息</span>

echo date(<span class="str">'Y-m-d H:i:s'</span>);
echo <span class="str">"<br/>\r\n"</span>;

echo <span class="str">'PHP获取Refer是:'</span>;
$refer=isset($_SERVER[<span class="str">'HTTP_REFERER'</span>])?$_SERVER[<span class="str">'HTTP_REFERER'</span>]:<span class="str">'No refer found'</span>;
echo $refer;
echo <span class="str">"<br/>\r\n"</span>;

echo <span class="str">'JS获取Refer是:'</span>;
    echo <span class="str">"<script>document.writeln(document.referrer);</script>"</span>;
echo <span class="str">"<br/>\r\n"</span>;

  
Copy after login

I am extremely curious as to why I was able to get it the first time but not the second time.

The environment is LNMPA, the official one is http://lnmp.org/lnmpa.html

Use charles to capture packets on Mac

The headers of the two requests to test1.php are consistent.

The headers of the two requests to test_cookie.php are consistent.

Then the question arises, what causes two identical requests and PHP cannot get the referrer. Kneel down and ask for answers.

For more exciting topics, follow Xiaowu’s blog http://www.lingdonge.com

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1048744.htmlTechArticlePHP cannot obtain Referer troubleshooting, referer troubleshooting test results: ?phpecho 'Test source: directly load the pagebr/ ' ;echo 'a href="test_cookie.php"Enter page/abr/' ;echo 'Test source...
Related labels:
php
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