$username, "password" => $password)); $options = array( 'http' => array( 'header' => "Content-Type: application/json\r\n", 'method' => 'POST', 'content' => $data, ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); $response = json_decode($result, true); return $response['authenticated']; } $isAuthenticated = authenticate($username, $password); if ($isAuthenticated) { $_SESSION['authenticated'] = true; echo json_encode(['authenticated' => true]); } else { $_SESSION['authenticated'] = false; echo json_encode(['authenticated' => false]); } ?>