Home >Web Front-end >JS Tutorial >P3P Header solves the problem of cookie cross-domain_javascript skills

P3P Header solves the problem of cookie cross-domain_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:40:341951browse

P3P

P3P is a standard called the Platform for Privary Preferences that protects online privacy and allows Internet surfers to choose whether their information is collected and used by third parties when browsing the web. personal information. If a site does not comply with P3P standards, its cookies will be automatically rejected, and P3P can also automatically identify various ways of embedding cookies. P3P was developed by the Global Information Alliance Network.

Example

When there is an iframe on the page, if you want to obtain the cookie in the iframe, you must add the P3P Header information to the corresponding dynamic page of the iframe, otherwise it cannot be obtained under IE. Because IE has a security policy that restricts pages from saving third-party cookies (note: the currently visited page is a first-party cookie, and third-party cookies are cookies from other web pages other than the current web page).

Copy code The code is as follows:

//http:// /www.a.com/a_setcookie.php File content:
setcookie("test", "testval", time() 3600, "/", ".a.com");
//http: //www.a.com/a_getcookie.php File content:
var_dump($_COOKIE);
/*---------------------- --------------------------------------------------
http://www.b.com/b_setcookie.php File content: