tree em
tree em

Reputation: 21781

lost session after Header redirect

 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 !";

    }

//After login successfully go to admin.php

session_start();

echo $_SESSION['username'];

Upvotes: 0

Views: 378

Answers (1)

nickf
nickf

Reputation: 546503

try setting the variable:

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

Upvotes: 1

Related Questions