double0201 2012-07-21 19:46
浏览 11

无法使用PHP检索某些cookie

I've got to be missing something simple, but this is driving me batty.

I'm setting a whole bunch of array cookies, like so:

setcookie("adjusted[$title]", $title, time() + 3600, "/", ".domain.com");

This works just fine, the cookies are being set and I can see them in the browser's cookie list.

However, I can't seem to read only certain values back out! I have no idea why. For example, I set this cookie:

adjusted[calldelivernow.net]

and I can see that is its name in Firefox's cookies page, the content is "calldelivernow.net". But all attempts to do this return false:

if(isset($_COOKIE["adjusted"]["calldelivernow.net"]))
    die("Cookie is set");

This is just one example of many, all under identical parameters just with different domain names. What on earth am I missing here? How can a cookie plainly exist in the browser, yet PHP not be able to read it?

  • 写回答

2条回答 默认 最新

  • douba5540 2012-07-21 19:49
    关注

    Because you're not calling it by it's name correctly. Unlike form names, cookies do not get stacked to arrays.

    Try $_COOKIE["adjusted[calldelivernow.net]"].

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答