访问1 b.com域后,我们并没有在2 a.com域发现设置上cookie值。 将http://www.a.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"); ?
再次访问: http://www.b.com/b_setcookie.php http://www.a.com/a_getcookie.php 在访问b.com域后,设置了a.com域的cookie值。 从上面例子可以看出通过发送P3P头信息而实现的跨域。(在Firefox不发送P3P也能跨域成功)PHP使用P3P协议 复制代码 代码如下: header( 'P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' );
JS使用P3P协议 复制代码 代码如下: xmlhttp.setRequestHeader( "P3P" , 'CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' );
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