返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >php怎么设置p3p头
  • 700
分享到

php怎么设置p3p头

php 2017-09-27 17:09:50 700人浏览
摘要

php设置p3p头的方法:1、编辑HOST,加入“127.0.0.1 www.a.com”;2、创建a_setcookie.php和a_getcookie.php等文件;3、通过header设置p3p头即可。

本文操作环境:windows7系统、PHP7.1版、Dell G3电脑。

php怎么设置p3p头?

PHP 通过设置P3P头来实现跨域访问COOKIE

我的是Centos的系统(linux 内核)

编辑HOST

vi /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

以上就是php怎么设置p3p头的详细内容,更多请关注编程界其它相关文章!

--结束END--

本文标题: php怎么设置p3p头

本文链接: https://www.lsjlt.com/news/142.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 初识P3P
    Google 标签: P3P, 第三方cookie, 隐私策略, http headP3P主要应用于网站跨域访问方面,全称为隐私偏好设定平台(platform for privacy preference, P3P)。而谈到P3P就不得不提 ...
    375
    2023-03-24
    P3P
  • p0p3与IMAP
    pop3:邮局协议,用户从远程邮箱下载邮件 特点:邮件下载 IMAP:internet 邮件访问协议,用户远程管理自己的邮箱 特点: 1,下载邮件的结构信息和邮件的子集 2,同时对多个远程邮箱的访问 3,多个客户机同时访问同一个邮箱 4,多 ...
    234
    2023-03-24
    IMAP
  • Oracle event p1 p2 p3
    在以下视图中都有P1,P2,P3参数selectfrom v$sessionselectfrom v$session_waitselect * from v$session_wait_history可从V$EVENT_NAME视 ...
    918
    2023-03-24
    oracle event p1 p2 p nt ev
  • css中p标签怎么设置高度
    这篇文章主要介绍“css中p标签怎么设置高度”,在日常操作中,相信很多人在css中p标签怎么设置高度问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”css中p标签怎么设置高度”的疑惑有所帮助!接下来,请跟着小编 ...
    391
    2023-03-24
    css
  • Python 3 进阶 —— 使用 P
    PyMySQL 是一个纯 Python 实现的 MySQL 客户端操作库,支持事务、存储过程、批量执行等。PyMySQL 遵循 Python 数据库 API v2.0 规范,并包含了 pure-Python MySQL 客户端库。安装pip ...
    382
    2023-03-24
    进阶 Python
  • setdefaultencoding p
    页面源代码如下#-*- coding: utf8 -*-import cgitb , cgicgitb.enable()form = cgi.FieldStorage()if (form.has_key("name") and form.h ...
    479
    2023-03-24
    setdefaultencoding
  • javascript如何设置p的值
    这篇文章主要讲解了“javascript如何设置p的值”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“javascript如何设置p的值”吧!javascript ...
    920
    2023-03-24
    javascript
  • html中如何对p设置float
    这篇文章主要介绍了html中如何对p设置float,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。float:left并排实例代码:.thang p{ float:left} ...
    523
    2023-03-24
    html float
  • spring + c3p0+hibern
    1:C3P0数据源的配置、sessionFactory托管给SPRING的配置。由于C3P0使用比较广泛,下面介绍C3P0在spring和hibernate3配置中的一些常用配置项,首先先把配置文件贴出来先,配置的文件名为dbContext ...
    287
    2023-03-24
    spring hibern
  • c3p0配置方式
    c3p0的配置方式分为三种,分别是1.setters一个个地设置各个配置项2.类路径下提供一个c3p0.properties文件3.类路径下提供一个c3p0-config.xml文件 1.setters一个个地设置各个配置项这种方式最繁琐, ...
    442
    2023-03-24
    方式
  • 如何根据入参 p1、p2、p3 等的不同组合进行策略定位
    这篇文章主要讲解了“如何根据入参 p1、p2、p3 等的不同组合进行策略定位”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何根据入参 p1、p2、p3 等的不同组合进行策略定位”吧!问题背 ...
    243
    2023-03-24
    if-else
  • html中p标签怎么用
    这篇文章给大家分享的是有关html中p标签怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。p 标签是我们的文本标签,p 标签会自动在其两个标签之间创建一些空白。删掉上段代码标签里的内容,把下面 ...
    543
    2023-03-24
    html
  • jquery怎么给p标签赋值
    使用jquery给标签p赋值的方法:1.新建html项目,引入jquery;2.创建p标签,设置id属性;3.添加button按钮,绑定onclick点击事件;4.通过id获取标签对象,使用text()方法赋值;具体步骤如下:1.首先,新建 ...
    558
    2023-03-24
    jquery
  • InspectionSystem---p
    inspectionsystem项目流水账  安装python 虚拟环境 ----virtualenvwrapper    mkvirtualenv inspectionsystem 环境名安装django  pip install dja ...
    267
    2023-03-24
    InspectionSystem
  • html如何设置p标签行间距
    这篇文章将为大家详细讲解有关html如何设置p标签行间距,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。html设置p标签行间距的方法是,给段落文字添加line-height属性,并且设置合理的行间距数值即 ...
    348
    2023-03-24
    html p标签
  • python3学习笔记(2)----p
    1、python3的基本数据类型Python 中的变量不需要声明。每个变量在使用前都必须赋值,变量赋值以后该变量才会被创建。在 Python 中,变量就是变量,它没有类型,我们所说的"类型"是变量所指的内存中对象的类型。等号(=)用来给变量 ...
    390
    2023-03-24
    学习笔记
  • centos 7 安装python3和P
    一、添加epel源yum install epel-release二、安装Python3.4,装完再升级吧yum install python34三、安装pip3yum install python34-setuptoolseasy_ins ...
    569
    2023-03-24
    centos
  • c3p0 - CLOSE BY CLIE
    from:http://hi.baidu.com/xhr8334/item/7e5a6f5326aa02d5d48bacca由一个DEBUG说开去先交代一下背景。昨天晚上一个群友在群里问我一个问题。他当时在给Oracle 10g配置C3P0 ...
    785
    2023-03-24
    CLOSE CLIE
  • jquery怎么获取p标签的值
    使用jquery获取p标签值的方法:1.新建html项目,引入jquery;2.创建p标签,设置id属性;3.添加button按钮,绑定onclick点击事件;4.通过id获取标签对象,使用text()方法获取值;具体步骤如下:1.首先,新 ...
    524
    2023-03-24
    jquery
  • c3p0的3种配置方式
    c3p0的配置方式分为三种,分别是1.通过setters方法一个个地设置各个配置项2.类路径下提供一个c3p0.properties文件3.类路径下提供一个c3p0-config.xml文件1.通过setters方法一个个地设置各个配置项 ...
    771
    2023-03-24
    properties c3p0
热门问答
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作