Home > php教程 > php手册 > PHP无法获取Referer问题排查,referer排查

PHP无法获取Referer问题排查,referer排查

WBOY
Release: 2016-06-13 08:55:42
Original
1526 people have browsed it

PHP无法获取Referer问题排查,referer排查

测试结果:

'测试来源:直接载入页面
'; echo '进入页面
'
; echo '测试来源:新窗口打开
'
; echo '进入页面
'
;

test_cookie.php的代码为:

<?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

极度好奇是什么原因造成的第一次能获取,第二次不能获取。

 

环境是LNMPA,官方是http://lnmp.org/lnmpa.html

 

Mac下用charles抓包

2次请求test1.php的header是一致的。

2次请求test_cookie.php的header是一致的。

 

那么问题来了,什么原因造成的2次完全一模一样的请求,PHP取不到refer。跪求解。

 

更多精彩话题关注小五博客http://www.lingdonge.com

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template