Toast Message after successful signed in

Hello,Use Bootstrap Toast message option is enable and $this->setSuccessMessage(“Signed in successfully.”); also showing message. But Toast with sweetalert2 mix is more graphical thats why if possible i wanted to use this in my project. I saw a post on this forum which is relevant to my expectation. Discussion link is : https://discourse.hkvstore.com/t/how-to-add-toast-message-on-successful-login/5026/4 tried the below code on Server Events → Page Foot. No error is showing but message is also not appearing:

if (isset($_SESSION['success_login'])) {
echo '<script>
function showtoasterlogin(){
        const Toast = Swal.mixin({
  toast: true,
  position: "top-end",
  showConfirmButton: false,
  timer: 3000,
  timerProgressBar: true,
  didOpen: (toast) => {
    toast.onmouseenter = Swal.stopTimer;
    toast.onmouseleave = Swal.resumeTimer;
  }
});
Toast.fire({
  icon: "success",
  title: "Signed in successfully"
});
}
window.onload = showtoasterlogin;
</script>';
 }

Any idea how can i do this?