最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP如何利用P3P實(shí)現(xiàn)跨域

 更新時(shí)間:2013年08月24日 09:17:39   作者:  
在開發(fā)中,我們碰到的跨域主要還是糾結(jié)在IE,頁面中的IFRAME或者FRAME或者JS跨域的時(shí)候,IE有安全策略限制頁面不帶cookie,但是如果我們加上P3P,就沒有這策略的限制。這也是P3P來突破跨域的可行前提

有別于JS跨域、IFRAME跨域等的常用處理辦法,還可以利用P3P來實(shí)現(xiàn)跨域。

P3P是什么
P3P(Platform for Privacy Preferences)是W3C公布的一項(xiàng)隱私保護(hù)推薦標(biāo)準(zhǔn),以為用戶提供隱私保護(hù)。

P3P標(biāo)準(zhǔn)的構(gòu)想是:Web 站點(diǎn)的隱私策略應(yīng)該告之訪問者該站點(diǎn)所收集的信息類型、信息將提供給哪些人、信息將被保留多少時(shí)間及其使用信息的方式,如站點(diǎn)應(yīng)做諸如 “本網(wǎng)站將監(jiān)測(cè)您所訪問的頁面以提高站點(diǎn)的使用率”或“本網(wǎng)站將盡可能為您提供更合適的廣告”等申明。訪問支持P3P網(wǎng)站的用戶有權(quán)查看站點(diǎn)隱私報(bào)告,然 后決定是否接受cookie 或是否使用該網(wǎng)站。

如何利用P3P實(shí)現(xiàn)跨域
在開發(fā)中,我們碰到的跨域主要還是糾結(jié)在IE,頁面中的IFRAME或者FRAME或者JS跨域的時(shí)候,IE有安全策略限制頁面不帶cookie,但是如果我們加上P3P,就沒有這策略的限制。這也是P3P來突破跨域的可行前提。

以下為摘錄的例子:
http://www.a.com/a_setcookie.php 文件內(nèi)容:
<?php setcookie("test", $_GET['id'], time()+3600, "/", ".a.com"); ?>
http://www.a.com/a_getcookie.php 文件內(nèi)容:
<?php var_dump($_COOKIE); ?>
http://www.b.com/b_setcookie.php 文件內(nèi)容:
<script src="http://www.a.com/a_setcookie.php?id=www.b.com"></script>
通過瀏覽器訪問:

復(fù)制代碼 代碼如下:

1?> http://www.b.com/b_setcookie.php
2?> http://www.a.com/a_getcookie.php

訪問1 b.com域后,我們并沒有在2 a.com域發(fā)現(xiàn)設(shè)置上cookie值。
將http://www.a.com/a_setcookie.php文件內(nèi)容改為如下:
復(fù)制代碼 代碼如下:

<?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域后,設(shè)置了a.com域的cookie值。
從上面例子可以看出通過發(fā)送P3P頭信息而實(shí)現(xiàn)的跨域。(在Firefox不發(fā)送P3P也能跨域成功)

PHP使用P3P協(xié)議

復(fù)制代碼 代碼如下:

header( 'P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' );

JS使用P3P協(xié)議
復(fù)制代碼 代碼如下:

xmlhttp.setRequestHeader( "P3P" , 'CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' );

P3P的頭部參數(shù)解釋
引用:
復(fù)制代碼 代碼如下:

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.


PS,這里說的跨域主要是設(shè)置cookie的情況,如果是跨域讀取cookie,要保證在對(duì)應(yīng)設(shè)置cookie的時(shí)候設(shè)置了P3P,否則在讀取的事情IE會(huì)屏蔽跨域cookie。

相關(guān)文章

  • 講解WordPress開發(fā)中一些常用的debug技巧

    講解WordPress開發(fā)中一些常用的debug技巧

    這篇文章主要介紹了WordPress開發(fā)中一些常用的debug技巧,需要的朋友可以參考下
    2015-12-12
  • PHP實(shí)現(xiàn)鏈表的定義與反轉(zhuǎn)功能示例

    PHP實(shí)現(xiàn)鏈表的定義與反轉(zhuǎn)功能示例

    這篇文章主要介紹了PHP實(shí)現(xiàn)鏈表的定義與反轉(zhuǎn)功能,結(jié)合實(shí)例形式分析了PHP鏈表的基本定義、添加、移除、遍歷以及兩種反轉(zhuǎn)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2018-06-06
  • PHP中使用DOMDocument來處理HTML、XML文檔的示例

    PHP中使用DOMDocument來處理HTML、XML文檔的示例

    這篇文章主要介紹了PHP中使用DOMDocument來處理HTML、XML文檔的示例,幫助大家更好的理解和學(xué)習(xí)使用php語言,感興趣的朋友可以了解下
    2021-04-04
  • php生成縮略圖的類代碼

    php生成縮略圖的類代碼

    最近做個(gè)項(xiàng)目,正好需要縮略圖的代碼,特給大家分享下
    2008-10-10
  • PHP中串行化用法示例

    PHP中串行化用法示例

    這篇文章主要介紹了PHP中串行化用法,結(jié)合實(shí)例形式分析了php使用serialize與unserialize函數(shù)實(shí)現(xiàn)串行化與反串行化操作的相關(guān)技巧,需要的朋友可以參考下
    2016-11-11
  • PHP在終端中實(shí)現(xiàn)進(jìn)度條來處理數(shù)據(jù)的示例詳解

    PHP在終端中實(shí)現(xiàn)進(jìn)度條來處理數(shù)據(jù)的示例詳解

    在PHP中,有時(shí)候你需要在終端中處理大量數(shù)據(jù)或執(zhí)行長時(shí)間運(yùn)行的任務(wù),同時(shí)希望能夠?qū)崟r(shí)跟蹤任務(wù)的進(jìn)度,在 PHP 中,有時(shí)候你需要在終端中處理大量數(shù)據(jù)或執(zhí)行長時(shí)間運(yùn)行的任務(wù),同時(shí)希望能夠?qū)崟r(shí)跟蹤任務(wù)的進(jìn)度,需要的朋友可以參考下
    2023-10-10
  • 小文件php+SQLite存儲(chǔ)方案

    小文件php+SQLite存儲(chǔ)方案

    在互聯(lián)網(wǎng)快速發(fā)展的背景下,網(wǎng)絡(luò)上的數(shù)據(jù)內(nèi)容呈幾何級(jí)的增長,而其中增長最快并且最容易給信息基礎(chǔ)架構(gòu)帶來挑戰(zhàn)的就是數(shù)目龐大的小文件(如圖片、電子圖書、郵件等)。
    2010-09-09
  • phpstudy安裝redis的操作步驟

    phpstudy安裝redis的操作步驟

    Redis?是一個(gè)開源的高性能鍵值存儲(chǔ)數(shù)據(jù)庫,廣泛用于緩存、消息隊(duì)列、會(huì)話管理和實(shí)時(shí)數(shù)據(jù)分析等應(yīng)用場(chǎng)景,本文給大家詳細(xì)介紹了phpstudy安裝redis的操作步驟,需要的朋友可以參考下
    2023-12-12
  • php中刪除數(shù)組的第一個(gè)元素和最后一個(gè)元素的函數(shù)

    php中刪除數(shù)組的第一個(gè)元素和最后一個(gè)元素的函數(shù)

    這篇文章主要介紹了php中刪除數(shù)組的第一個(gè)元素和最后一個(gè)元素的函數(shù),需要的朋友可以參考下
    2015-03-03
  • 關(guān)于PHP語言構(gòu)造器介紹

    關(guān)于PHP語言構(gòu)造器介紹

    你提到的“語言構(gòu)造器”,英文是”language construct”,是語言構(gòu)成的意思,翻譯成語言構(gòu)造器難免有點(diǎn)令人困惑
    2013-07-07

最新評(píng)論

长丰县| 万年县| 平乡县| 青阳县| 绥芬河市| 墨江| 天柱县| 遵义县| 泸州市| 白城市| 内黄县| 吴堡县| 石楼县| 安陆市| 双桥区| 白朗县| 万全县| 金湖县| 化隆| 建昌县| 黄石市| 宜宾县| 久治县| 旅游| 台南市| 斗六市| 阿瓦提县| 怀柔区| 山丹县| 沭阳县| 扎鲁特旗| 玛沁县| 福建省| 恩平市| 威海市| 金寨县| 白朗县| 西丰县| 轮台县| 金阳县| 蒙阴县|