prepare("SELECT sender, message FROM chat_log WHERE session_id = ? ORDER BY created_at ASC"); $stmt->execute([$_SESSION['session_id']]); $chat_history = $stmt->fetchAll(); } catch (PDOException $e) { // Not critical if history fails to load, so we just log it. error_log("Could not load chat history: " . $e->getMessage()); } } ?>