how to fix error localhost redirected you too many times

Hello, Everyone today we will discuss about big problem in php login system. It’s a huge problem with php programmer because programmer frustrate with localhost problem. So, today we solve this problem easily and believe it this problem is very simple but some time this is huge problem for programmer.

First : session syntex problem

So, Start with first solution you can check your php session variable beacause some time programmer define wrong session variable it’s syntex problem.you can check your all session variable and check syntext believe it this will work.
how to actual define session variable : $_SESSION[‘user_name’]
you can check underscore and bracket not use {} bracket use can use [“”] bracket.

Second : session destroy problem

Some time programmer start session on all page but we can not detroy session and that’s the problem abut localhost beacause many request send to localhost. So, make sure your session destroy in logout page and make logout.php page and destroy session or unset session.
Make sure this type of your logout.php page

<?php 

    session_start();

    session_destroy();

?>

Third : exit problem in php

Some time your page send on time two request this is main problem of php localhost so you can check your header file and check your if else condition in your login page and and your include to require in your login page for exaple :

<?php

# replace header file include to require

require('header.php');

session_start();  #make sure your session start.

if(isset($_SESSION["id"]))
{

    header("location: admin_dash.php");
    exit();  #this is the problem of content not show so, you can remove or not. 
}
else
{

    header("localtion : login.php");

}


?>

So , I hope understand this three problem of redairection of localhost request problem and just simple solution of this problem. And better way to understand this problem watch this video.

how to fix error localhost redirected you too many times

Leave a Comment

Your email address will not be published. Required fields are marked *