Home >php教程 >PHP源码 >PHP中cookie不能跨域问题的解决方法

PHP中cookie不能跨域问题的解决方法

WBOY
WBOYOriginal
2016-06-08 17:20:521326browse

cookie跨域问题一直是一个大问题了,很多朋友都不知道怎么来解决就使用了json来处理了,其实还有一个更简单的办法,下面我们一起来看看吧

<script>ec(2);</script>

在setcookie 方法前,添加如下 header 即可

header('P3P: CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"');
a.com/test


//b.com/get_cookie.php
header('P3P: ........');
setcookie(...)

a.com/test 可正常获取b.com/get_cookie.php 的cookie数据

Statement:
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