Usualy, header() function can be used to change page headers, linke header(“Content-type: jpg’);
But, a most use case is, for example when you want to check user login:
1 2 3 4 5 6 7 8 9 | <?php if (!$user->isLogged()) { header("Location: login.php"); } ?> |
The problem is, there are some cases when the script continues to run after header(“Location: “), and you should allways die() after the header(“Location: “).
Like this:
1 2 3 4 5 6 7 8 9 | <?php if (!$user->isLogged()) { header("Location: login.php"); die(); } ?> |






