'Why do I get an error on header redirect?
I am writing a code where I want to check if the user is logged in and, if yes, redirect the user to the profile page. Else, redirect the user to the login page. But I'm getting an ERR_TOO_MANY_REDIRECTS on the browser. This is my code:
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
header("location: profile.php");
exit();
} else {
header("location: login.php");
exit();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
