I'm trying to get the id of a user that logged in and saved it in the session, but it's not working, I make a query in the database at the time of logging and I transform the result into an array to get the id and store it in the session , but this is giving undefined index id, ta ai the code that logs in
try{
$select = ("SELECT * FROM usuario WHERE nome=:usuario AND senha=:senha AND status=1");
$logarusuario = $pdo->prepare($select);
$logarusuario->bindValue(":usuario", $usuario);
$logarusuario->bindValue(":senha", $senha);
$logarusuario->execute();
$linhas = $logarusuario->rowCount();
$result = $logarusuario->fetchAll(PDO::FETCH_OBJ);
if($linhas > 0){
$_SESSION['usuario'] = $usuario;
$_SESSION['senha'] = $senha;
$_SESSION['id'] = $result['id'];
$_SESSION['logged_success'] = 'você foi logado com sucesso';
header(5,"Location:../logado.php");
}else{
header("Location:../index.php");
echo "Dados Digitados Incorretos";
}
}catch(PDOException $e){
echo $e;
}
?>