php如何設(shè)置p3p頭

php如何設(shè)置p3p頭,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

10年的茄子河網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整茄子河建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“茄子河網(wǎng)站設(shè)計(jì)”,“茄子河網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

php設(shè)置p3p頭的方法:1、編輯HOST,加入“127.0.0.1 www.a.com”;2、創(chuàng)建a_setcookie.php和a_getcookie.php等文件;3、通過header設(shè)置p3p頭即可。

本文操作環(huán)境:windows7系統(tǒng)、PHP7.1版、Dell G3電腦。

php怎么設(shè)置p3p頭?

PHP 通過設(shè)置P3P頭來實(shí)現(xiàn)跨域訪問COOKIE

我的是CentOS的系統(tǒng)(Linux 內(nèi)核)

編輯HOST

vi /etc/hosts

加入

127.0.0.1        www.a.com
127.0.0.1        www.b.com

首先:創(chuàng)建 a_setcookie.php 文件,內(nèi)容如下:

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

然后:創(chuàng)建 a_getcookie.php 文件,內(nèi)容如下:

<?php 
var_dump($_COOKIE); 
?>

最后:創(chuàng)建 b_setcookie.php 文件,內(nèi)容如下:

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

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

三個(gè)文件創(chuàng)建完畢后,我們通過瀏覽器依次訪問:

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

我們會(huì)發(fā)現(xiàn),在訪問b.com域的時(shí)候,我們并沒有在a.com域設(shè)置上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

這次,你會(huì)發(fā)現(xiàn)在訪問b.com域的時(shí)候,我們設(shè)置了a.com域的cookie值。

末了補(bǔ)充一句,似乎只有IE對跨域訪問COOKIE限制比較嚴(yán)格,上述代碼在FIREFOX下測試,即使不發(fā)送P3P頭信息,也能成功。

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

undefined

通過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

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。

分享標(biāo)題:php如何設(shè)置p3p頭
URL鏈接:http://muchs.cn/article40/gecpho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google網(wǎng)站維護(hù)、App開發(fā)、企業(yè)網(wǎng)站制作、網(wǎng)站導(dǎo)航、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化