0

I've a simple question. After my user is logged of i want to show a popup. The problem here is that php code runs before the javascript code. Is there a way to show my popup after i redirect?

<head>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
</head>

<?php
   session_start();
   session_destroy();
   header("Location: Login.html");
   echo '<script>swal("Oops..", "Because of inactivity, you where logged off", "info")</script>';
?>
Luca
  • 25
  • 3

1 Answers1

1

header("Location: login.html?popup=true");

file login:

if(isset($_GET['popup'])){ echo 'swal("Oops..", "Because of inactivity, you where logged off", "info")'; }

  • 1
    Thanks for answering a question on StackOverflow! Your answer looks right, but it's a little hard to read without code formatting. You can easily format your code blocks by indenting them: https://stackoverflow.com/editing-help#code – antun Apr 28 '20 at 17:53