im trying to redirect after a successful login, code as follows:
//if success (if there is a row)
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
// make the server ready for a session
session_start();
$_SESSION['userId'] = $row['user_id'];
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['user_role'] = $row['user_role'];
$_SESSION['status'] = "ok";
session_write_close();
//get user_role for proper redirection
$iUserRole = $row['user_role'];
if($iUserRole==0){
header('Location: ../admin.php');
exit();
} else if($iUserRole==1){
header('Location: ../user.php');
exit();
} else if($iUserRole==2){
header('Location: ../partner.php');
exit();
}
i can see in the browser that the admin.php is downloaded.
the php is called with:
$.ajax({
url: 'ajax_api/login_auth.php',
type: 'POST',
data: {
"sEmail": sEmail,
"sPassword": sPassword
},
})
.fail(function() {
console.log("jquery ajax login_auth error");
}).success(function(data) {
console.log(data);
});
and the console.log(data) logs the entire html page html/text.