结果试图获得非对象的属性

This will probably be tagged as duplicate but might as well try since I can't get a specific solution.

my controller function seems to result to "Trying to get property of non-object" error. I want to get a specific data from an index of an array. the array is from a Session data that I used in another page.

function within my controller
        public function checkPwd()
        {
            $oldPwd = $this->input->post('oldPass');//getting POST data from ajax
            $newPwd = $this->input->post('newPass');//getting POST data from ajax

            $currLogged = $this->session->all_userdata();
            foreach ($currLogged as $log) 
            {

                echo $log->pwd; //this results to Trying to get property of non-object

            }
        }

You can access it as

echo $currLogged['logged'][0]->pwd

In foreach you can access it as

foreach($currLogged as $log){

    echo $log[0]->pwd;
}