Hello, When I call a php file using Ajax, I do this :
function logIntoApp(){
Ext.Ajax.request({
url:'php/login.php',
params:{
action:'login',
email:Ext.getCmp('userLogin').getValue(),
motDePasse:Ext.getCmp('passwordLogin').getValue()
},
method:'GET',
success:function(result, request){
//Ext.MessageBox.alert('Success', );
if(result.responseText == 'admin'){
//Ext.MessageBox.alert('Alert', result.responseText);
window.location.replace("administration.php");
}
else if(result.responseText == 'pro'){
//Ext.MessageBox.alert('Alert', result.responseText);
window.location.replace("proAdministration.php");
}
else{
Ext.MessageBox.alert('Alert', result.responseText);//'Email ou mot de passe incorrect!');
}
},
failure:function(result, request){
Ext.MessageBox.alert('Failed', 'Erreur de chargement de données');
}
});
}
in my php file, I set a $_SESSION to use it in my administration.php
if($role=='Administrateur'){
$_SESSION['role']='admin';
$_SESSION['email']=$email;
$message = 'admin';
}
And in my administration.php, I have this :
<?php
session_start();
echo "alert(''". $_SESSION['role'] . ")";
if($_SESSION['role']=='admin'){
//echo "alert('pro')";
}
else{
//echo "alert('admin')";
header("Location:index.php");
}
?>
And in my index.php I have this :
<?php
session_start();
$_SESSION['role']='visiteur';
$_SESSION['email']='no';
?>
the problem is that I'm never redirected to administration.php, I think because the $_SESSION['role'] is never set as 'admin'