$type, 'message' => $message ]; } function get_flash_message() { if (isset($_SESSION['flash'])) { $flash = $_SESSION['flash']; unset($_SESSION['flash']); return $flash; } return null; } // API Response helper function json_response($data, $status = 200) { header('Content-Type: application/json'); http_response_code($status); echo json_encode($data); exit(); }