PHP 通过设置P3P头来实现跨域访问COOKIE

我的是CentOS的系统(Linux 内核)

编辑HOST 

vi /etc/hosts

加入

127.0.0.1        www.a.com

127.0.0.1        www.b.com

首先:创建 a_setcookie.php 文件,内容如下:

<?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"
); 
?>

然后:创建 a_getcookie.php 文件,内容如下:

<?php 
var_dump($_COOKIE
); 
?>

最后:创建 b_setcookie.php 文件,内容如下:

<script src="http://www.a.com/a_setcookie.php?id=www.b.com"></script>

----------------------------

三个文件创建完毕后,我们通过浏览器依次访问:

http://www.b.com/b_setcookie.php
http://www.a.com/a_getcookie.php

我们会发现,在访问b.com域的时候,我们并没有在a.com域设置上cookie值。

然后我们修改一下a_setcookie.php文件,去掉注释符号,a_setcookie.php即为:

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

末了补充一句,似乎只有IE对跨域访问COOKIE限制比较严格,上述代码在FIREFOX下测试,即使不发送P3P头信息,也能成功。

==========================================

通过Fiddler可以方便的知道上面P3P代码的含义

P3P Header is present:
CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"

Compact Policy token is present. A trailing 'o' means opt-out, a trailing 'i' means opt-in.

CURa
Information is used to complete the activity for which it was provided.

ADMa
Information may be used for the technical support of the Web site and its computer system.

DEVa
Information may be used to enhance, evaluate, or otherwise review the site, service, product, or market.

PSAo
Information may be used to create or build a record of a particular individual or computer that is tied to a pseudonymous identifier, without tying identified data (such as name, address, phone number, or email address) to the record. This profile will be used to determine the habits, interests, or other characteristics of individuals for purpose of research, analysis and reporting, but it will not be used to attempt to identify specific individuals. 

PSDo
Information may be used to create or build a record of a particular individual or computer that is tied to a pseudonymous identifier, without tying identified data (such as name, address, phone number, or email address) to the record. This profile will be used to determine the habits, interests, or other characteristics of individuals to make a decision that directly affects that individual, but it will not be used to attempt to identify specific individuals.

OUR
We share information with ourselves and/or entities acting as our agents or entities for whom we are acting as an agent.

BUS
Info is retained under a service provider's stated business practices. Sites MUST have a retention policy that establishes a destruction time table. The retention policy MUST be included in or linked from the site's human-readable privacy policy.

UNI
Non-financial identifiers, excluding government-issued identifiers, issued for purposes of consistently identifying or recognizing the individual. These include identifiers issued by a Web site or service.

PUR
Information actively generated by the purchase of a product or service, including information about the method of payment.

INT
Data actively generated from or reflecting explicit interactions with a service provider through its site -- such as queries to a search engine, or logs of account activity.

DEM
Data about an individual's characteristics -- such as gender, age, and income.

STA
Mechanisms for maintaining a stateful session with a user or automatically recognizing users who have visited a particular site or accessed particular content previously -- such as HTTP cookies.

PRE
Data about an individual's likes and dislikes -- such as favorite color or musical tastes.

COM
Information about the computer system that the individual is using to access the network -- such as the IP number, domain name, browser type or operating system.

NAV
Data passively generated by browsing the Web site -- such as which pages are visited, and how long users stay on each page.

OTC
Other types of data not captured by the above definitions.

NOI
Web Site does not collected identified data.

DSP
The privacy policy contains DISPUTES elements.

COR
Errors or wrongful actions arising in connection with the privacy policy will be remedied by the service.


Validate at: http://www.w3.org/P3P/validator.html
Learn more at: http://www.fiddlertool.com/redir/?id=p3pinfo

 

 

参考文档:http://www.w3.org/P3P/

转载于:https://www.cnblogs.com/jackluo/archive/2013/03/03/2941393.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/421939.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

硬盘计算机类比推理,判断推理类比推理:储存:光盘:硬盘 A:晾晒:绳索:衣架 B.吃...

判断推理类比推理&#xff1a;储存&#xff1a;光盘&#xff1a;硬盘A&#xff1a;晾晒&#xff1a;绳索&#xff1a;衣架B.吃文章来源&#xff1a; 编辑者&#xff1a;yangshengliang 时间&#xff1a;2019-02-26 11:01:141、储存&#xff1a;光盘&#xff1a;硬盘A&#xff1…

计算机考试打字对齐,2010年职称计算机考试:对齐方式

对齐是指单元格内容相对于单元格边框线的显示位置。除了使用Excel默认的对齐方式以外,用户还可以自己设置数据的对齐方式,以使工作表美观、整齐。(1)水平对齐操作步骤:1)选取欲设置对齐方式的单元格或单元格区域。2)选取"格式"菜单中的"单元格"命令,出现&q…

MySQL查询结果条数编号示例 mysql 查找结果中自动加序号列

SELECT row : row 1 as row, t.id FROM sgcorp_product t, (SELECT row : 0) r where t.id not in(select product_id from sgcorp_pic) http://database.51cto.com/art/201011/235142.htm http://blog.csdn.net/macwhirr123/article/details/7489484转载于:https://www.cnb…

噪音曲线图测试软件,利用示波器统计工具分析有噪声信号之测量统计和余晖图...

利用示波器统计工具分析有噪声信号之测量统计和余晖图2019-09-24数字示波提供了多种基于统计的工具&#xff0c;除了前文提到的平均和直方图之外&#xff0c;测量参数统计和余晖图&#xff0c;也是非常有用的工具&#xff0c;协助快速获取有用信息。对于示波器测量参数&#xf…

第十讲:Obj-C Blocks 应用

转&#xff1a;http://tigercat1977.blog.163.com/blog/static/2141561122012111295955891/ 第十讲&#xff1a;Obj-C Blocks 应用 2012-12-12 09:59:55| 分类&#xff1a; Objective-C | 标签&#xff1a;objective-c |字号大中小 订阅 主要内容Blocks 是什么Blocks 和…

计算机右键菜单太多,电脑点击右键太多选项怎么办

1. 鼠标右键新建里有太多选项,怎么删除没用的选项清除方法&#xff1a;1&#xff0c;以下代码粘贴进TXT文本文档&#xff1b;2&#xff0c;文档另存后&#xff0c;命名为“.cmd”后缀&#xff0c;保存到桌面&#xff1b;3&#xff0c;双击该文档&#xff0c;即可自动清理。清除…

javascript递归函数问题

最近在看《Professional Javascript For Web Developers 3rd Edition》&#xff0c;看到关于递归函数调用的问题&#xff0c;在此记录备忘&#xff1a; 先定义一个递归函数&#xff0c;求正整数N的阶乘&#xff1a; function factorial(num){if(num<1)return 1;return num*f…

计算机成绩表及格率怎么算,卫生资格人机对话如何考试如何评分?成绩如何核算?...

原标题&#xff1a;卫生资格人机对话如何考试如何评分&#xff1f;成绩如何核算&#xff1f;世事悠悠浑未了&#xff0c;年光冉冉今如许。今天距离考试只有30天啦&#xff01;大家都做好冲刺准备了吗&#xff1f;眼看离考试越来越近&#xff0c;今儿就跟大家说说人机考试的那些…

坚持的力量 第一篇

第一篇 风筝 在阳光明媚的春天&#xff0c;听着孙燕姿的《风筝》&#xff0c;我陶醉了&#xff0c;我用我的笔端刷新着我的思维&#xff0c;我的成长。 “天空的风筝哪去了&#xff0c;你知不知道”&#xff0c;“穿越云端&#xff0c;飞的更高&#xff0c;把梦想找到”。…

OD 学校的位置

/*** 题目描述&#xff1a;* 为了解决新学期学生暴涨的问题&#xff0c;小乐村要建所新学校。考虑到学生上学安全问题&#xff0c;需要所有学生家到学校距离最短。* 假设学校和所有的学生家&#xff0c;走在一条直线上。 请问&#xff0c;学校要建在什么位置&#xff0c;能使得…

商务计算机的购置方案,电子采购方案的实施.ppt

《电子采购方案的实施.ppt》由会员分享&#xff0c;可在线阅读&#xff0c;更多相关《电子采购方案的实施.ppt(10页珍藏版)》请在人人文库网上搜索。1、第三节 电子采购方案的实施,一、实施电子采购的技术支持,二、实施电子采购的步骤,一、实施电子采购的技术支持,数据库技术&a…

HDOJ1014 Uniform Generator

Problem : 1014 ( Uniform Generator ) Judge Status : AcceptedRunId : 7742145 Language : C Author : qq1203456195Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta 依题意可知&#xff0c;只要两个数的最大公约数为1就ok了~ 1 #include …

查询应用服务器fc端口wwn号,FAQ-如何查询应用服务器HBA卡的WWN号

解决方案Windows操作系统1、在Windows应用服务器上安装软件“scli-1[1].06.16-29.windows.msi”。2、在桌面上单击该软件的快捷方式。系统自动启动该软件&#xff0c;并出现如图1所示的界面。图1 操作选择界面3、在“Enter Selection:”后输入4并按“Enter”键。系统出现如图2所…