Header重定向后丢失会话

时间:2010-03-31 02:54:48

标签: php

 session_start();
//login page
if(mysql_num_rows($result) != '0'){ // If match.

        session_register("username"); // Craete session username.

        header("location:admin/admin.php"); // Re-direct to admin.php    
    exit;

    }else{ // If not match.

        $message="Please Incorrect your account !";

    }

//登录成功后转到admin.php

session_start();

echo $ _SESSION ['username'];

1 个答案:

答案 0 :(得分:1)

尝试设置变量:

if (mysql_num_rows($result)) {
    $_SESSION['username'] = "something";
    header(....); exit;
} // etc