dongtou2016 2011-10-27 15:16
浏览 42
已采纳

无法在PHP中检索cookie

enter image description here

I have a cookie that I've set on my site called "your-selected-location". I'm in FF and using firebug I can see that the cookie is set seemingly correctly and does not expire until next year and is stored in the root "/". However if I run the following code in very top of my PHP file it does not return the cookie value (which I can see in Firebug)

if (isset($_COOKIE[ 'your-selected-location' ]))
    {
        $cookieselectedlocation = $_COOKIE['your-selected-location'];
        echo ("<hr>Your cookie is: $cookieselectedlocation<hr>");
    }

I've also tried a direct echo:

echo $_COOKIE[ 'your-selected-location' ];

With no luck. Any thoughts? Thanks!

Chris

EDIT: Here's where it gets weirder: www.site.com/merchant_profile --> Cannot read cookies site.com/merchant_profile --> CAN read cookies

  • 写回答

3条回答 默认 最新

  • dqlk31541 2011-10-27 18:17
    关注

    OK, problems solved. The www.site.com vs. site.com led me to another stack overflow post that explains it all: PHP cookie problem - www or without www

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器