日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

转载 - 通过设置P3P头来实现跨域访问COOKIE

發布時間:2025/1/21 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 转载 - 通过设置P3P头来实现跨域访问COOKIE 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

作者:老王

網上看了別人介紹的一片文章,說使用P3P可以完成跨域COOKIE操作,感覺很COOL,不過沒有提供源代碼,我胡亂寫了一下,大家看看。

實際工作中,類似這樣的要求很多,比如說,我們有兩個域名,我們想實現在一個域名登錄后,能自動完成另一個域名的登錄,也就是PASSPORT的功能。

我只寫一個大概,為了測試的方便,先編輯hosts文件,加入測試域名(C:\WINDOWS\system32\drivers\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



文章說的主要是跨域設置COOKIE的情況,如果是跨域讀取COOKIE的情況,只要保證在對應設置COOKIE的時候設置P3P即可,否則在讀取的事情IE會屏蔽跨域COOKIE。在Internet Explorer Cookie Internals (FAQ)一文里對這個情況有描述。

參考文檔:http://www.w3.org/P3P/

原文地址:http://hi.baidu.com/thinkinginlamp/blog/item/5e2a02084f1dafd163d9865f.html

總結

以上是生活随笔為你收集整理的转载 - 通过设置P3P头来实现跨域访问COOKIE的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 午夜精品视频在线观看 | 毛片com | 日韩午夜在线播放 | 在线看黄免费 | 日韩美女激情视频 | 中文字字幕 | 中文一区在线 | 中文字幕在线观看日韩 | 久久久久亚洲AV成人无码国产 | 91 高清 在线 制服 偷拍 | 色吧在线观看 | 国产aⅴ片 | 一区二区亚洲视频 | 总受合集lunjian双性h | 2023av在线 | 日韩欧美亚洲精品 | 久艹视频在线观看 | 丁香花婷婷 | 中文在线观看免费网站 | 天堂在线中文字幕 | 欧美一区二区三区成人久久片 | 嫩草嫩草嫩草嫩草 | 免费视频二区 | 粉嫩av渣男av蜜乳av | 精品午夜久久久 | 波多野结衣三级视频 | 欧美一级少妇 | 色爽 av| 天天操夜夜夜 | 91精品久久久久久久久久久 | www.中文字幕.com| 豆花av在线| 污污视频免费观看 | 一区二区三区在线免费播放 | www.色就是色 | 天堂在线中文资源 | 中文字幕免费播放 | 青青青草视频在线观看 | 久久av一区二区三区 | 黄色av国产 | 男人天堂久久 | 成人私密视频 | 免费国产一区 | 妺妺窝人体色www在线小说 | 91在线视频免费观看 | 国产xxxxwwww | 久久手机视频 | 精品一区二区三区毛片 | 精品视频久久久久久久 | 欧美日韩图片 | 人妻久久一区二区 | 日韩精品极品 | 欧美精品第二页 | 福利视频免费观看 | 欧美a一级 | 国内视频一区二区三区 | 日韩毛片一级 | 乳揉みま痴汉4在线播放 | 四季av在线一区二区三区 | 精品人妻无码中文字幕18禁 | 亚洲色图一区二区三区 | 午夜国产福利 | h视频免费在线 | 国产成人 综合 亚洲 | 免费毛片网站 | 黄色自拍网站 | 国产视频自拍一区 | 日本黄色一区二区三区 | 欧美日韩国产一区二区 | 暖暖av在线 | 一区二区三区四区av | 中文字幕第五页 | 免费成人在线观看动漫 | 国产精品一区二区三区在线 | 日日骚网 | 亚洲国产精品一区 | 1024亚洲| 奇米精品一区二区三区在线观看 | 国产91精品看黄网站在线观看 | 亚洲吧| 日韩精品在线一区 | 成人免费在线看片 | 桃色视频在线 | 向着小小的花蕾绽放 | 久久精品国产视频 | 中文字幕丰满乱子伦无码专区 | 中文在线字幕观看 | 911久久| 波多野结衣av无码 | 2021久久| 日韩在线观看网址 | 91资源在线观看 | 日韩一级在线播放 | 国产成人精品无码免费看81 | 国产精品成人久久 | www.成人免费 | 中文字幕亚洲精品在线观看 | 日本天堂网在线观看 | 亚洲欧美精品午睡沙发 |