I have an strange problem which I can't find out what is causing this behaviour.
I have an page called dashboard.php where I have this code:
mail('xxx@gmail.com', 'Dashboard 1', 'isLoggedin = ' . $isLoggedIn);
if(!$isLoggedIn) {
header("Location: https://example.com/account/login.php");
}
mail('xxx@gmail.com', 'Dashboard 2', 'Dashboard 2');
If the user isn't logged on the dasboard.php page, he must be redirected to the login.php page.
When I am not logged in and go to dashboard.php, the following happened:
Why get I the second mail but I am redirected to the login.php so the script in dashboard.php shouldn't get so far? Why is the script after the redirect still running?
as shown in php.net docs, you have to exit;
your script, otherwise it will be executed.