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

php怎么设置p3p头

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

本文操作环境:windows7系统、PHP7.1版、Dell G3电脑。php怎么设置p3p头?PHP 通过设置P3P头来实现跨域访问COOKIE我的是Centos的系统(linux 内核)编辑HOST vi /etc/hosts加入127

本文操作环境: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 head P3P主要应用于网站跨域访问方面,全称为隐私偏好设定平台(platform for privacy preference, P3P)。而谈到P3P就不得不...
    381
    2023-09-29
    P3P
  • p0p3与IMAP
    pop3:邮局协议,用户从远程邮箱下载邮件 特点:邮件下载 IMAP:internet 邮件访问协议,用户远程管理自己的邮箱 特点: 1,下载邮件的结构信息和邮件的子集 2,同时对多个远程邮箱的访问 3,多个客户机同时访问同一个邮箱 4,多...
    235
    2023-09-29
    IMAP
  • Oracle event p1 p2 p3
    在以下视图中都有P1,P2,P3参数 select from v$sessionselect from v$session_waitselect * from v$sess...
    918
    2023-09-29
    oracle event p1 p2 p nt ev
  • java p2p模块怎么实现
    要实现Java P2P模块,您可以遵循以下步骤:1. 创建一个基本的P2P节点类,该类应该包含节点的唯一标识符,IP地址和端口号等信...
    191
    2023-09-29
    java
  • Python 3 进阶 —— 使用 P
    PyMySQL 是一个纯 Python 实现的 MySQL 客户端操作库,支持事务、存储过程、批量执行等。 PyMySQL 遵循 Python 数据库 API v2.0 规范,并包含了 pure-Python MySQL 客户端库。 安装...
    386
    2023-09-29
    进阶 Python
  • css中p标签怎么设置高度
    这篇文章主要介绍“css中p标签怎么设置高度”,在日常操作中,相信很多人在css中p标签怎么设置高度问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”css中p标签怎么设置高度”...
    397
    2023-09-29
    css
  • setdefaultencoding p
    页面源代码如下 #-*- coding: utf8 -*- import cgitb , cgi cgitb.enable() form = cgi.FieldStorage() if (form.has_key("na...
    480
    2023-09-29
    setdefaultencoding
  • javascript如何设置p的值
    这篇文章主要讲解了“javascript如何设置p的值”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“javascript如何设置p的值”吧! ...
    922
    2023-09-29
    javascript
  • html中如何对p设置float
    这篇文章主要介绍了html中如何对p设置float,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。 float:left 并排实例代码:....
    525
    2023-09-29
    html float
  • php去掉p标签的方法
    这篇文章主要介绍php去掉p标签的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!php去掉p标签的方法:首先打开相应的PHP文件;然后通过php正则表达式“preg_replace("/|<\ p...
    112
    2023-09-29
  • spring + c3p0+hibern
    1:C3P0数据源的配置、sessionFactory托管给SPRING的配置。由于C3P0使用比较广泛,下面介绍C3P0在spring和hibernate3配置中的一些常用配置项,首先先把配置文件贴出来先,配置的文件名为dbContext...
    287
    2023-09-29
    spring hibern
  • c3p0配置方式
    c3p0的配置方式分为三种,分别是 1.setters一个个地设置各个配置项 2.类路径下提供一个c3p0.properties文件 3.类路径下提供一个c3p0-config.xml文件   1.setters一个个地设置各个配置项 这...
    442
    2023-09-29
    方式
  • P3-Weixin是什么框架
    这篇文章给大家分享的是有关P3-Weixin是什么框架的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。P3-Weixin是轻量级Java插件开发框架,采用主流JAVA技术,集成强大代码生成器,增删改查一键生成,封装...
    136
    2023-09-29
  • Java C3P0链怎么用
    这篇“Java C3P0链怎么用”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Java C3P0链怎么用”文章吧。0 ...
    483
    2023-09-29
  • 如何根据入参 p1、p2、p3 等的不同组合进行策略定位
    这篇文章主要讲解了“如何根据入参 p1、p2、p3 等的不同组合进行策略定位”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何根据入参 p1、p2、p3 等...
    243
    2023-09-29
    if-else
  • android WebRtc 视频通话(P2P)
    概述      WebRTC名称源自网页实时通信(Web Real-Time Communication)的缩写,是一个支持网页浏览器进行实时语音对话或视频对话的技术,是谷歌2010年以6820万美元收购Global IP Solutio...
    878
    2023-09-29
    p2p android webrtc
  • InspectionSystem---p
    inspectionsystem项目流水账   安装python 虚拟环境 ----virtualenvwrapper     mkvirtualenv inspectionsystem 环境名 安装django   pip instal...
    267
    2023-09-29
    InspectionSystem
  • set /p=命令怎么用
    这篇文章将为大家详细讲解有关set /p=命令怎么用,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。set 命令详解 在批处理中回显信息有两个命令,echo和set /p=<nul,它们的共同点在于都...
    497
    2023-09-29
  • *p++和(*p)++有什么区别
    本篇内容介绍了“*p++和(*p)++有什么区别”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!“*p++”和“(*p)++”的区别是:1、“...
    244
    2023-09-29
  • Android WiFi P2P数据传输
    WiFi P2P是指通过WiFi直接连接两台设备之间的无线点对点通信,不需要通过路由器或者互联网。这种技术被广泛应用于移动设备之间的文件共享、游戏联机、音乐播放等应用场景中。 WiFi P2P的优点在...
    475
    2023-09-29
    android p2p 网络协议 wifi
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作