PHP - 利用P3P兑现跨域

WBOY
Release: 2016-06-13 13:04:23
Original
753 people have browsed it

PHP - 利用P3P实现跨域

http://www.a.com/a_setcookie.php 文件内容:

http://www.a.com/a_getcookie.php 文件内容:

http://www.b.com/b_setcookie.php 文件内容:

通过浏览器访问:
1?> http://www.b.com/b_setcookie.php
2?> http://www.a.com/a_getcookie.php
访问1 b.com域后,我们并没有在2 a.com域发现设置上cookie值。

将http://www.a.com/a_setcookie.php文件内容改为如下:
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); ??
setcookie("test", $_GET['id'], time()+3600, "/", ".a.com"); ?
?>
再次访问:
http://www.b.com/b_setcookie.php
http://www.a.com/a_getcookie.php
在访问b.com域后,设置了a.com域的cookie值。

从上面例子可以看出通过发送P3P头信息而实现的跨域。(在Firefox不发送P3P也能跨域成功)

Related labels:
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