简体   繁体   English

如何使用PHP获取浏览器cookie列表?

[英]How to get a list of browser cookies using PHP?

From my understanding $_COOKIE gives me all the cookies in a user's browser. 根据我的理解, $_COOKIE在用户的浏览器中提供了所有cookie。

But when I do 但是,当我这样做

var_dump($_COOKIE);

I get the following: 我得到以下内容:

Array
    (
        [wp-settings-1] => m8=o&m2=o&m5=o&m4=o&m3=o&m1=o&m7=o&m0=o
        [wp-settings-time-1] => 1329859655
        [PHPSESSID] => ST88bLB7PE5S9BbY5oXxLgDIcas
    )

This list does not match the list I see in the browser. 此列表与我在浏览器中看到的列表不匹配。 For example, PHPSESSID is not in the list of cookies in my browser. 例如,PHPSESSID不在我的浏览器的cookie列表中。 Am I accessing the wrong variable? 我是否访问了错误的变量?

Thanks. 谢谢。

As mentioned $_COOKIE only gives you cookies for the current domain/path. 如上所述$_COOKIE只为您提供当前域/路径的cookie。 You cannot see all cookies in a browser. 您无法在浏览器中看到所有Cookie。 You can see how this works if you ever sniff/view HTTP packets. 如果你嗅探/查看HTTP数据包,你可以看到它是如何工作的。 When you make an HTTP request, the browser sends cookies to the server. 当您发出HTTP请求时,浏览器会将cookie发送到服务器。 This page has some excellent examples of what that HTTP traffic looks like. 此页面提供了一些HTTP流量外观的优秀示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM