PHP에서 p3p 헤더를 설정하는 방법: 1. HOST를 편집하고 "127.0.0.1 www.a.com"을 추가합니다. 2. a_setcookie.php 및 a_getcookie.php와 같은 파일을 생성합니다. 3. 헤더를 통해 p3p 헤더를 설정합니다.
이 문서의 운영 환경: Windows 7 시스템, PHP 버전 7.1, Dell G3 컴퓨터.
PHP에서 p3p 헤더를 설정하는 방법은 무엇입니까?
PHP는 P3P 헤더를 설정하여 COOKIE에 대한 도메인 간 액세스를 달성합니다
내 시스템은 CentOS(Linux 커널)입니다.
Edit HOST
vi /etc/hosts
Join
127.0.0.1 www.a.com 127.0.0.1 www.b.com
먼저 다음을 사용하여 _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 도메인에 있습니다.
그런 다음 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 도메인의 쿠키 값이 설정됩니다.
마지막으로 IE만이 COOKIE에 대한 도메인 간 액세스를 더 엄격하게 제한하는 것으로 보입니다. 위 코드는 FIREFOX에서 테스트되었으며 P3P 헤더 정보를 보내지 않고도 성공할 수 있습니다.
===========================================
추천 공부 : " PHP 동영상 튜토리얼》
위 P3P 코드의 의미는 Fiddler
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를 통해 쉽게 알 수 있습니다.
위 내용은 PHP에서 p3p 헤더를 설정하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!