How to fix undefined array key "status_login" index.php on line 3

Viewed 9

index.php How to fix undefined array key "status_login" index.php on line 3 i can't fix that

session_start();
        if($_SESSION['status_login'] !== true){
           echo '<script>window.location="pages/login.php"</script>';
        }

login.php

  if(isset($_POST['submit'])){
      session_start();
      include 'db.php';

      $user = $_POST['user'];
      $pass = $_POST['pass'];


      $cek = mysqli_query($conn, "SELECT * FROM admin WHERE username = '".$user."' AND password = '".$pass."'");
      if( mysqli_num_rows($cek) > 0){
          $d = mysqli_fetch_object($cek);
          $_SESSION['status_login'] = true;
          $_SESSION['a_global'] = $d;
          $_SESSION['id'] = $d->id_admin;
          echo '<script>window.location="../index.php"</script>';
      } else{
          echo '<script>alert("Username atau Password anda salah!")</script>';
      }
  }
0 Answers
Related