title: localhost redirected you too many times when using header ()
body: <p>Hi am getting this error when I am trying to send a redirect to the login page.
  here is my code...</p>
  
  <blockquote>
    <p>The localhost page isn’t working</p>
    
    <p>localhost redirected you too many times. Try clearing your cookies.
    ERR_TOO_MANY_REDIRECTS</p>
  </blockquote>
  
  <p>anything I am trying it's giving me this error.</p>
  
  <p>any suggestions would be much appreciated, thank you!</p>
  
  <pre><code>&lt;?php 
  if(!$session-&gt;is_signed_in()){
  
      header("Location:login.php");
  
  
      } else{
           header("Location:logout.php");
  
  } ?&gt;
  </code></pre>
  
  <p>and this </p>
  
  <pre><code>class Session{
  
      private $signed_in = false;
      public $user_id;
  
      public function __construct(){
              session_start();
          $this-&gt;check_the_login();
  
      }
  // check the value of signed in property - getter method
  
      public function is_signed_in(){
  
          return $this-&gt;signed_in;
      }
  
  // login method 
  
      public function login($user){
  
          if($user){
              $this-&gt;user_id = $_SESSION['user_id'] = $user-&gt;id;
              $this-&gt;signed_in = true;
          }
  
  
      }
  // log out method 
  
      public function logout(){
  
          unset($this-&gt;$_SESSION['user_id']);
          unset($this-&gt;user_id);
          $this-&gt;signed_in = false;
  
  
      }
  
  
  // check the login method
  
      private function check_the_login(){
  
              if(isset($_SESSION['user_id'])){
  
                  $this-&gt;user_id = $_SESSION['user_id'];
                  $this-&gt;signed_in = true;
  
              }else{
  
                  unset($this-&gt;user_id);
                  $this-&gt;signed_in = false;
              }
  
          }
      }
  
  $session = new Session();
  </code></pre>