把php.ini中的session.auto_start改成1

解决方案 »

  1.   

    session_start()目标页也加了阿??
      

  2.   

    同意 dream_river(铁马兵河入梦来)
      

  3.   

    session.auto_start改为1,是不是等同于所有的页面加session_start()???
    我把完整的代码发给大家,大家帮忙!!!!a.php
    <?
    @$q1 = $_POST['q1'];
    if(!empty($q1))
    {
      $key1 = '1';
      if($q1==$key1)
      {
        session_start();
        $_SESSION['authorized'] = true;
        //header('Location: register.php');
       }
       else
       {
          echo('<font color=red>wrong!!!</font>');
       }
       exit;
    }
    ?>
    <html>
    <head>
    <title>Answer my question!</title>
    </head>
    <body>
    <form method=post action='b.php'>
    <p>who's called 'donkey'?</p>
    <input type=radio name=q1 value=1>1
    <input type=radio name=q1 value=2>2
    <input type=radio name=q1 value=3>3
    <input type=radio name=q1 value=4>4
    <input type=radio name=q1 value=5>5
    </form>
    </body>
    </html>b.php
    <?
    if(!empty('authorized'))
    {
    header('Location: a.htm');
    exit;
    }
    echo('hello,boy!!!');
    ?>每次都跳回a.htm!!!
    如果你答错一次,,他就可以正确显示hello,boy!!!
    而且
    如果我将a.php的header(...)替换为:
    echo('<meta http-equiv="refresh" content="0;url=register.php">');
    运行正确!!!!为什么!!???这个问题郁闷我好几天了!!!!!
      

  4.   

    注册session变量用
    session_register("变量名");
    如:
    $authorized=true;
    session_reister("authorized");b.php
    <?
    session_start();
    if(!empty('authorized'))
    {
    header('Location: a.htm');
    exit;
    }
    echo('hello,boy!!!');
    ?>
    应该可以的.