A cookie is domain and path specificif you want to access cookies from other paths, try to add a path of "/" to them, for example"name=value; path=/;"

解决方案 »

  1.   

    cookie默认作用域为当前目录和子目录,可以加上路径来控制作用域.
    例如,下面让sess_name可以作用于整个站点
    setcookie("sess_name","xxx",time()+30000,"/");
      

  2.   

    setcookie是不是也象header一样,都不能向浏览器输出任何东西前用setcookie,对吧
    可是我在一开始都用setcookie,但是还是说
    Warning: Cannot add header information - headers already sent by (output started at /home/simple/index13.php:2) in /home/simple/index13.php on line 16
    请问指的是什么呢
      

  3.   

    setcookie前面不能有任何输出,包括空格空行