title: Log in Validation alert pop up even though i'm not login yet
body: <p>I try to make an alert for invalid login so I use</p>
  <pre><code>$this-&gt;session-&gt;set_flashdata('error', 'Invalid Credentials');  
              redirect(&quot;admin/login&quot;);
  </code></pre>
  <p>and i put this in my index function</p>
  <pre><code>$data=[];
      if (isset($_SESSION['error'])) {
  
          $data['error']=$_SESSION['error'];
      }else{
          $data['error']=&quot;NO_ERROR&quot;;
  
      }
      
      //$this-&gt;load-&gt;helper('url');
      $this-&gt;load-&gt;view('adminpanel/loginview',$data);
  </code></pre>
  <p>but when i reload my login page, the alert was already execute, can anyone help me  with this?
  this is my full controller</p>
  <pre><code>public function index()
  {
  
      $data=[];
      if (isset($_SESSION['error'])) {
  
          $data['error']=$_SESSION['error'];
      }else{
          $data['error']=&quot;NO_ERROR&quot;;
  
      }
      
      //$this-&gt;load-&gt;helper('url');
      $this-&gt;load-&gt;view('adminpanel/loginview',$data);
  
  }
  
  function login_post(){
      //$this-&gt;load-&gt;helper('url'); set at autoload file
      // print_r($_POST); test the post result
       if (isset($_POST)) {
          $email=$_POST['email'];
          $password=$_POST['password'];
  
          $query = $this-&gt;db-&gt;query(&quot;SELECT * FROM `backenduser` WHERE `username`='$email' AND `password`='$password'&quot;);
  
          if ($query-&gt;num_rows()) {
              // credential are valid
  
              $result = $query-&gt;result_array();
                  //echo &quot;&lt;pre&gt;&quot;;
              //print_r($result); die();
  
              $this-&gt;session-&gt;set_userdata('user_id', $result[0]['uid']);
  
              redirect('admin/dashboard');
  
          }
          else{
              //invalid credentials
              $this-&gt;session-&gt;set_flashdata('error', 'Invalid Credentials');  
              redirect(&quot;admin/login&quot;);
          }
  
       }
       else{
          die(&quot;Invalid Input!&quot;);
       }
  }
  
  function logout(){
      session_destroy();
  }
  </code></pre>
  <p>}</p>