output_buffering = Off时怎么使用session?

解决方案 »

  1.   

    代码?
    session_start() 要在所有输出之前
      

  2.   

    session_start() 一用就出现Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\esw\admin\admin_login.php:1) in C:\AppServ\www\esw\admin\admin_login.php on line 2Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\esw\admin\admin_login.php:1) in C:\AppServ\www\esw\admin\admin_login.php on line 2
    这个错误
      

  3.   

    <?php
    session_start();
    include("../include/user.php");
    include("../config.inc.php");
    if(isset($_POST['imageField'])){
    $user=new user();
    $name=trim($_POST['guestname']);
    $psd=md5(trim($_POST['guestpass']));
    $login=$user->login($name,$psd);
    foreach($login as $value){
    if($value["name"]!=""){
    //$_SESSION['name']=$name;
    setcookie("name",$name,time()+3600,'/');
    echo $_COOKIE['name'];exit;
    //$GLOBALS['name']=$name;
    //$GLOBALS['SESSION']['psd']=$psd;
    //$GLOBALS['SESSION']['gid']=$gid;
    echo "<meta http-equiv=refresh content='0; url=index.php'>";
    }else{
    echo "<meta http-equiv=refresh content='0; url=index.php'>";
    }
    exit;
    }
    }
    ?>
      

  4.   

    你那个报错是说你在用session_start()的时候前面已经有输出了,所以报错,检查一下程序
      

  5.   

    <?php前面不能有空格换行
    另外你用什么编辑器写的,是不是保存了utf8格式,注意不能有bom
      

  6.   

    可是没有啊 在执行这个页面的时候不是一开始就session_start()了吗 然后在include吗 前面什么都没有 
      

  7.   

    默认情况下session是需要利用cookie来记录session id的,而cookie则是在http response header中发送,所以必须在输出之前,那个报错就是这个意思
      

  8.   

    第一次遇到这样的服务器 吐血了 先是不支持url分段,现在又搞个output——buffing=off
      

  9.   

    什么是url分段?注意你的admin_login.php是否用带有bom的utf8保存,不要使用记事本保存为utf8,稍微高级一些的编辑器都有选项
      

  10.   

    http://www.williamlong.info/archives/171.html
      

  11.   

    绝对没有bom 我用编辑器改的 没用记事
      

  12.   

    编辑器有选项,另存为一下确定没选,还有你的这个admin_login是直接访问还是被include
      

  13.   

    http://www.williamlong.info/archives/171.html我早上就看了 没用
      

  14.   

    别的页面session_start没问题?用winhex或者ultraedit看看16进制,你用的什么编辑器?新建一个<?php session_start();print_r($_SESSION);看看有没有问题
      

  15.   

    都不行 都有问题 把outbut_buffing打开就好了 不打开都有问题
      

  16.   

    @ini_set('session.auto_start',1);
    @ini_set('session.save_path',"/");这个我也设了,也没用
      

  17.   

    http://www.neowin.net/forum/lofiversion/index.php/t350711.html
    找到了 就是这个了服务器