$_SERVER['HTTP_COOKIE'] 返回两个 PHPSESSID [英] $_SERVER['HTTP_COOKIE'] return's two PHPSESSID

查看:21
本文介绍了$_SERVER['HTTP_COOKIE'] 返回两个 PHPSESSID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在打印 $_SERVER['HTTP_COOKIE'] 时得到两个 PHPSESSID.其实我不知道它是如何设置两次的,它只在我的本地系统中.当我检查 SERVER cookie 时,它​​就像:

I am getting two PHPSESSID while printing $_SERVER['HTTP_COOKIE']. Actually I don't know how it is set twice, its only in my local system. When I check the SERVER cookie it like:

echo $_SERVER['HTTP_COOKIE'];

//result 

'fe_toolbar=false; 
fe_toolbar=false; 
PHPSESSID=4tvbovcjk0msf9dvibeb31c2b7; 
langId=1; 
backendLangId=2; 
PHPSESSID=46aagg1hg7as2uh9bihjlpp8h7'

当我单独检查我的 cookie 时:

When I check my cookie alone like :

print_r($_COOKIE);    

//result 

array (
       'fe_toolbar' => 'false',
       'PHPSESSID' => '4tvbovcjk0msf9dvibeb31c2b7',
      )

推荐答案

您可以拥有多个同名的 cookie.当您使用不同的路径或域属性设置 cookie 时会发生这种情况.它们全部发送到服务器.

You can have multiple cookies with the same name. This happens when you set cookie with different Path or Domain attributes. They are all send to the server.

RFC 6265 特定的

如果 Cookie 标头包含两个同名的 Cookie(例如,设置了不同的路径或域属性),服务器不应该依赖于这些 cookie 在标题中出现的顺序.

if the Cookie header contains two cookies with the same name (e.g., that were set with different Path or Domain attributes), servers SHOULD NOT rely upon the order in which these cookies appear in the header.

您的 $_COOKIE 将填充这些值之一.

Your $_COOKIE will be populated with one of these values.

这篇关于$_SERVER['HTTP_COOKIE'] 返回两个 PHPSESSID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆