Can you help me? thanks


Hi, I am doing a mobile application and I require the use of web service, in order to pass data in a better way I require to use sessions, what happens is that I save the sessions in the first php and I see if I keep in them and it contains the data, but when I do the query in the second php then it says “undefined index: rutTecnico”, beforehand thank you very much.

Theres is my code


session_start(); //Llamar conexion 
mysqli_set_charset($con, "utf8"); 
$data = json_decode(file_get_contents('php://input'), true); 
$buscar = $data["Rut"]; 
$sql = "SELECT Tecnico.Nombre, Tecnico.Rut, cms_User.Password FROM Tecnico INNER JOIN cms_User ON Tecnico.Correo = cms_User.Id WHERE Rut='$buscar'"; 
if(!$resulta = mysqli_query($con, $sql)) die(); 
$json_array = array(); 
while($row = mysqli_fetch_assoc($resulta)) { 
  $json_array['Usuarios'][] = $row; 
  $ruG = $row['Rut']; 
  $noG = $row['Nombre']; 
$_SESSION['rutTecnico'] = $ruG; 
$_SESSION['nombreTecnico'] = $noG; 
echo json_encode($json_array); //Cerrar conexion mysqli_close($con); 


$rut = $_SESSION['rutTecnico']; 
$nombre = $_SESSION['nombreTecnico']; 
$json_array = array("Tecnico" =>["Rut"=>"$rut","Nombre"=>"$nombre"]); 
echo json_encode($json_array); 


Hi @petertohen!

undefined index: rutTecnico

This means variable $_SESSION["ruTecnico"] is undefined.

Please check your first script and verify if $_SESSION["ruTecnico"] is properly set. Make sure it is not null