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();
}
?>
Keywords
Related Questions
- Are there any specific steps to ensure that the newly installed PHP version is recognized by Plesk and Contao?
- What are the best practices for grouping and displaying data from a database using PHP, particularly when dealing with complex queries?
- What are some best practices for handling file permissions and file downloads in PHP scripts?