日韩性视频-久久久蜜桃-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的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 日本在线三级 | 日本高清视频在线观看 | 韩国性猛交╳xxx乱大交 | 天天干夜夜怕 | 国产精品第157页 | 久久99精品久久久久子伦 | 操碰视频在线 | 91精品国产自产在线观看 | 午夜精品一区二区三区在线观看 | 国产又粗又长又黄的视频 | 欧美a大片 | 在线视频中文字幕 | 色婷婷av一区二区三区之红樱桃 | 在线永久看片免费的视频 | 国产一区二区视频网站 | 午夜视频在线瓜伦 | 奴色虐av一区二区三区 | 国产精久久一区二区三区 | 巨胸挤奶视频www网站 | 欧美亚洲国产一区二区三区 | 国产情侣露脸自拍 | 好男人www日本 | 天天超碰 | 羞羞涩涩视频 | 日韩经典一区 | 亚洲国产成 | 伊人超碰在线 | 久久精品这里 | 日批网址| 亚洲黄页网站 | 国产精品h | 黄色在线观看网址 | 一区二区三区在线免费播放 | 黑人欧美一区二区三区 | 欧美一区二区三区四区在线 | 熟女人妻在线视频 | 久久伊人av | 九一九色国产 | 国产精品一区二区人人爽 | 学生孕妇videosex性欧美 | 成人午夜影视在线观看 | 日韩午夜小视频 | 亚洲激情欧美色图 | 色屁屁 | www.猫咪av | 亚洲巨乳| 国产高潮在线 | 91精品国产综合久久福利 | 懂色av一区二区三区四区五区 | 9999精品| 国产aⅴ无码片毛片一级一区2 | 日本少妇全体裸体洗澡 | 国产最新自拍 | 精品久久久久一区二区国产 | 天天干天天搞天天射 | 国产精品成人久久久 | 久草麻豆| 人人看人人澡 | 欧美黑人xxxⅹ高潮交 | 修女也疯狂3免费观看完整版 | 日韩va视频 | 97视频久久| 久久情趣视频 | 欧美无遮挡高潮床戏 | 50一60岁老妇女毛片 | 中文字幕亚洲综合 | 久久激情网站 | 风流还珠之乱淫h文 | 欧美一区二区 | 久久久久久久久久久网 | 国产精品一级二级三级 | 毛片在线免费观看网站 | 天天摸天天爽 | 福利一二三区 | 色人综合| 香蕉av一区| 国产成人精品免高潮在线观看 | 中文字幕99页| 国产尤物av| 精品五月天 | yellow免费在线观看 | 亚洲视频黄 | 天天撸在线视频 | www久久久天天com | 精品欧美一区二区精品少妇 | 国产午夜一区 | 亚洲av久久久噜噜噜熟女软件 | 黄色激情视频在线观看 | 久久青娱乐| 国产在线97 | 日韩一二三区 | 亚欧三级 | 无码人妻精品一区二区三区66 | 第一色综合 | 欧美一级黄色大片 | 久久精品97 | 黄色av免费在线观看 | 亚洲精品欧美在线 | 黄色国产片|