title: Cannot use object of type stdClass as array codeigniter
body: <p>I'm building a project in <code>CodeIgniter</code> and trying to create a <code>login</code> functionality.</p>
  
  <p>I just created a session on logging and passed the logged in user's id to the dashboard, but it showing me an error. Here is my code.</p>
  
  <p>My controller - login controller ---------</p>
  
  <pre><code>class Login extends CI_Controller {
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('Auth_model','',true);
      }
  
      public function index(){
          $this-&gt;load-&gt;view('login/index');
      }
  
      public function verifyUser(){
          $userArray = array(
              "email"=&gt;$this-&gt;input-&gt;post("email"),
              "password"=&gt;$this-&gt;input-&gt;post("password"),
          );   
          $loggedUserData = $this-&gt;Auth_model-&gt;checkUser($userArray);  
          var_dump($loggedUserData);
          if(count($loggedUserData)&gt;0){
              // this is where we creating session
             $this-&gt;session-&gt;set_userdata('loggedUserData',$loggedUserData);
             //redirect('dashboard/index');       
          }else{
             redirect('login');        
          }
      }
      public function logout(){
          $this-&gt;session-&gt;sess_destroy();
          redirect('login');
      }
  }
  </code></pre>
  
  <p>My Model - Auth_model ---------</p>
  
  <pre><code>class Auth_model extends CI_model{  
      public function __construct() {
          parent::__construct();
      }
      public function checkUser($userArray){
          $loggedUserData = $this-&gt;db-&gt;select('id')
               -&gt;where('email',$userArray["email"])
               -&gt;where('password',$userArray["password"])
               -&gt;get('users');
          return $loggedUserData-&gt;row();
          // here we are going to check the user with db
      }
  }
  </code></pre>
  
  <p>My view - dashboard------------</p>
  
  <pre><code>class Dashboard extends CI_Controller {
      public function __construct() {
          parent::__construct();
          $currentUserData = $this-&gt;session-&gt;userdata();
          if(!isset($currentUserData["loggedUserData"])){
              redirect('/login/');
          }
      }
      public function index(){
          //$this-&gt;load-&gt;view('dashboard/index');
          echo $this-&gt;session-&gt;userdata['loggedUserData']['id'];
      }
  }
  </code></pre>
  
  <p>Please help me out.</p>