print_r($_COOKIE); 輸出結果為  array()是不是什么域的问题。该怎么设置

解决方案 »

  1.   

    当浏览器请求一个页面时,如果检测到有与该页面同域且没有过期的cookie字段,就会在请求头里边加入cookie的信息。因此需要确认的是,
    aaa.html和bbb.php实在同一个域吗?或者aaa.html的过期时间是多少呢?
      

  2.   

    经过测试不会丢失,下面是我的测试与代码()
    //建立cookie<?php
    setcookie('my["id"]',"myid",time()+560);
    ?>
    <script>location.href='test.html' </script>//test.html
    <script>location.href='page2.php' </script>
    //page2.php<?php
    print_r($_COOKIE['my']);
    ?>打印结果:
    Array ( ["id"] => myid )