广告
返回顶部
首页 > 资讯 > 后端开发 > 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

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • php怎么设置p3p头
    本文操作环境:windows7系统、PHP7.1版、Dell G3电脑。php怎么设置p3p头?PHP 通过设置P3P头来实现跨域访问COOKIE我的是CentOS的系统(Linux 内核)编辑HOST vi /etc/hosts加入127...
    99+
    2017-09-27
    php
  • php怎么设置数组头部增加
    在PHP中,要在数组头部增加元素可以使用多种方法。在本篇文章中,我们将会介绍两种常见的方法,一种是使用array_unshift函数,另一种是使用“+”运算符。以下是详细解释:方法一:使用array_unshift函数array_unshi...
    99+
    2023-05-19
  • Node.js中怎么设置HTTP头
    Node.js中怎么设置HTTP头,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。server.js//basic server的配置...
    99+
    2022-10-19
    node.js http
  • springboot怎么设置响应头
    在Spring Boot中,可以通过使用`@RestController`注解标注一个类,并且使用`@RequestMapping`...
    99+
    2023-10-25
    springboot
  • qtableview怎么设置表头文本
    您可以使用以下代码设置QTableView的表头文本:```python# 设置表头文本model = QStandardItemM...
    99+
    2023-09-22
    qtableview
  • vue-resouce中怎么设置请求头
    本篇文章为大家展示了vue-resouce中怎么设置请求头,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。第一种:在Vue实例中设置var vm ...
    99+
    2022-10-19
  • 怎么从头开始设置webpack 5
    本篇内容主要讲解“怎么从头开始设置webpack 5”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么从头开始设置webpack 5”吧!如果你是从 webpa...
    99+
    2022-10-19
    webpack
  • nginx中proxy_set_head怎么设置头部信息
    nginx中proxy_set_head怎么设置头部信息,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。导读反向代理服务器是一种代理服务器,用于管理从外部网络到内部网络的连接或任...
    99+
    2023-06-05
  • HttpClient请求中怎么设置Content-Type标头
    本篇文章给大家分享的是有关HttpClient请求中怎么设置Content-Type标头,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。POST...
    99+
    2022-10-19
    httpclient content-type
  • PHP的header()函数:如何设置HTTP响应头
    PHP是一种常用的服务器端脚本语言,用于动态网页、网站开发和服务器管理等。在PHP中,使用header()函数可以设置HTTP响应头,控制某些HTTP协议参数,实现功能增强和安全保障等。本文将为您介绍如何使用PHP的header()函数设置...
    99+
    2023-11-03
    设置 HTTP响应头 header()函数
  • php头编码实例设置方法及代码
    在PHP中可以通过在PHP文件头部添加“header("Content-type: text/html; charset=utf-8");”语句来设置编码。 设置utf编码的代码如下...
    99+
    2022-11-12
    php 头编码
  • 怎么设置小程序页面头部的颜色
    设置小程序页面头部颜色的案例:小程序导航顶部配置都写在.json文件中。{"window":{"navigationBarBackgroundColor": "#ffffff&qu...
    99+
    2022-10-17
    小程序 小程序页面
  • Vue怎么为GET或POST请求设置请求头
    这篇文章主要介绍了Vue怎么为GET或POST请求设置请求头的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Vue怎么为GET或POST请求设置请求头文章都会有所收获,下面我们一起来看看吧。为GET或POST请求...
    99+
    2023-06-29
  • Win8怎么更改用户头像以及Win8动态头像设置教程
    Win8系统相比Win7要改进不少,比如在头像方面Win8将可以更加个性化,不仅可以使用传统的图片头像,甚至还可以使用动态视频作为头像,下面本文就与大家分享下Win8头像相关技巧,分别会介绍下Win8怎么更...
    99+
    2022-06-04
    头像 教程 动态
  • php怎么设置星期
    本文操作环境:windows7系统、PHP7.1版、DELL G3电脑php怎么设置星期?PHP星期几获取代码:date("l"); //data就可以获取英文的星期比如Sunday date("w"...
    99+
    2019-12-26
    php
  • php 怎么设置空格
    本文操作环境:windows7系统、PHP7.1版、DELL G3电脑php 怎么设置空格?php给每个段落添加空格的方法本文实例讲述了php给每个段落添加空格的方法。分享给大家供大家参考。具体实现方法如下:<php //Prepe...
    99+
    2017-11-15
    php 空格
  • php pdo怎么设置utf8
    本文操作环境:Windows7系统、PHP7.4版、DELL G3电脑php pdo怎么设置utf8在PHP中PDO解决中文乱码问题设置utf8:$this->pdo = new PDO($dsn, $user, $password,...
    99+
    2019-12-05
    php pdo tf8
  • php curl怎么设置cookie
    本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑。php curl怎么设置cookiePHP CURL中传递cookie的方法步骤curl的cookie怎么使用新手都很头疼的,curl的参数太多了,其中cookie部分...
    99+
    2021-04-11
    php curl cookie
  • PHP中怎么设置Cookie
    PHP中怎么设置Cookie,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。PHP经过长时间的发展,很多用户都很了解PHP了,这里我发表一下关于PHP Cooki...
    99+
    2023-06-17
  • php怎么设置SESSION ID
    本篇内容主要讲解“php怎么设置SESSION ID”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“php怎么设置SESSION ID”吧!session_id()获取或设置Session会话 I...
    99+
    2023-06-20
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作