<?php
$msg = $_SESSION['login_msg'] ?? '';
$alert_type = $_SESSION['alert_type'] ?? '';
$redirect_url = $_SESSION['redirect_url'] ?? '';
?>

<!-- SweetAlert Trigger -->
<script>
    <?php if (!empty($msg)) { ?>
        Swal.fire({
            position: 'center',
            icon: '<?php echo $alert_type; ?>',
            title: '<?php echo addslashes($msg); ?>',
            showConfirmButton: true,
            confirmButtonText: 'Okay',
        }).then(() => {
            <?php if (!empty($redirect_url)) { ?>
                window.location.href = '<?php echo $redirect_url; ?>';
            <?php } ?>
        });
    <?php } ?>
</script>
<?php
unset($_SESSION['login_msg'], $_SESSION['alert_type'], $_SESSION['redirect_url']);
?>
