How can the automatic redirection after 3 seconds in a PHP script be improved to prevent re-execution of the login script?
The issue can be solved by adding a session variable to track if the redirection has already occurred. By checking this variable before executing the redirection, we can prevent the login script from being re-executed.
<?php
session_start();
if(!isset($_SESSION['redirected'])){
$_SESSION['redirected'] = true;
header("refresh:3;url=dashboard.php");
exit();
}
?>