Link to home
Start Free TrialLog in
Avatar of prashanth ag
prashanth ag

asked on

php " this webpage has a redirect loop "

I am using the following code in  login.php
if (isset($_SESSION['username'])){
  if($_SESSION['type'] != "Admin"){
header('Location: panel/index.php');
}
else if($_SESSION['type'] != "Manager"){
header('Location: admin/index.php');
}
else 
{
header('Location: Manager/index.php');
}

Open in new window

I get the error during login
this webpage has a redirect loop ( chrome )
webpage isn't  redirecting properly  (Firefox )
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Without knowing more about the rest of your app, it's difficult to know. For example, what happens in panel/index.php or admin/index.php - it's possible that this page tries to redirect to there, that page doesn't think there's a user logged in so redirects back to the login page - and so on!!

Also, you're logic seems a little off.

If 'type' is anything but Admin, the first if block will be fired.
If it is Admin, then the second block will be fired
The third block will never be fired!
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial