title: Get spesific filed name in the $session codeigniter
body: <p>I want to get the ID of the logged-in user , and i print out the following line</p>
  
  <pre><code>echo "&lt;pre&gt;"; print_r($this-&gt;session-&gt;userdata());
  </code></pre>
  
  <p>The result is as follows :</p>
  
  <pre><code>Array
  (
    [__ci_last_regenerate] =&gt; 1449132599
  [lang] =&gt; english
  [userdata] =&gt; User_model Object
      (
          [table] =&gt; er_users
          [primaryKey] =&gt; user_id
          [primaryLabel] =&gt; user_name
          [usertype] =&gt; user_type
          [rules] =&gt; Array
              (
                  [user_id] =&gt; integer
                  [user_type] =&gt; required|integer
                  [user_name] =&gt; required|min_length[3]
                  [user_email] =&gt; required|valid_email
                  [user_pass] =&gt; min_length[8]|max_length[16]
                  [user_pconf] =&gt; required|matches[user_pass]
                  [user_mobile] =&gt; required|min_length[10]
                  [user_avatar] =&gt; 
                  [user_code] =&gt; required|integer
                  [user_status] =&gt; required|integer
              )
  
          [forms] =&gt; Array
              (
                  [*] =&gt; Array
                      (
                          [user_id] =&gt; Array
                              (
                                  [field] =&gt; user_id
                              )
  
                          [user_type] =&gt; Array
                              (
                                  [field] =&gt; user_type
                                  [type] =&gt; select:hasOne[Admin/Setting][value][name^=user_type]
                              )
  
                          [user_name] =&gt; Array
                              (
                                  [field] =&gt; user_name
                              )
  
                          [user_email] =&gt; Array
                              (
                                  [field] =&gt; user_email
                              )
  
                          [user_pass] =&gt; Array
                              (
                                  [field] =&gt; user_pass
                                  [type] =&gt; password
                              )
  
                          [user_pconf] =&gt; Array
                              (
                                  [field] =&gt; user_pconf
                                  [type] =&gt; password
                              )
  
                          [user_mobile] =&gt; Array
                              (
                                  [field] =&gt; user_mobile
                                  [type] =&gt; mobile
                              )
  
                          [user_avatar] =&gt; Array
                              (
                                  [field] =&gt; user_avatar
                                  [type] =&gt; select:hasOne[Admin/User::avatars][avatar]
                              )
  
                          [user_code] =&gt; Array
                              (
                                  [field] =&gt; user_code
                              )
  
                          [user_status] =&gt; Array
                              (
                                  [field] =&gt; user_status
                                  [type] =&gt; select:hasOne[Admin/Setting][value][name^=user_status]
                              )
  
                      )
  
                  [list] =&gt; Array
                      (
                          [user_id] =&gt; Array
                              (
                              )
  
                          [user_type] =&gt; Array
                              (
                              )
  
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                          [user_status] =&gt; Array
                              (
                              )
  
                      )
  
                  [search] =&gt; Array
                      (
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                      )
  
                  [create] =&gt; Array
                      (
                          [user_type] =&gt; Array
                              (
                              )
  
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_pass] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                          [user_status] =&gt; Array
                              (
                              )
  
                      )
  
                  [edit] =&gt; Array
                      (
                          [user_id] =&gt; Array
                              (
                                  [type] =&gt; hidden
                              )
  
                          [user_type] =&gt; Array
                              (
                              )
  
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_pass] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                          [user_status] =&gt; Array
                              (
                              )
  
                      )
  
                  [show] =&gt; Array
                      (
                          [user_id] =&gt; Array
                              (
                              )
  
                          [user_type] =&gt; Array
                              (
                              )
  
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                          [user_status] =&gt; Array
                              (
                              )
  
                      )
  
                  [edit_account] =&gt; Array
                      (
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_pass] =&gt; Array
                              (
                              )
  
                          [user_mobile] =&gt; Array
                              (
                              )
  
                          [user_avatar] =&gt; Array
                              (
                              )
  
                      )
  
                  [register] =&gt; Array
                      (
                          [user_name] =&gt; Array
                              (
                              )
  
                          [user_email] =&gt; Array
                              (
                                  [rules] =&gt; required|valid_email|is_unique[er_users.user_email]
                              )
  
                          [user_pass] =&gt; Array
                              (
                              )
  
                          [user_pconf] =&gt; Array
                              (
                              )
  
                      )
  
                  [lost] =&gt; Array
                      (
                          [user_email] =&gt; Array
                              (
                              )
  
                      )
  
                  [reset] =&gt; Array
                      (
                          [user_email] =&gt; Array
                              (
                              )
  
                          [user_code] =&gt; Array
                              (
                              )
  
                          [user_pass] =&gt; Array
                              (
                              )
  
                      )
  
                  [delete] =&gt; Array
                      (
                          [user_id] =&gt; Array
                              (
                                  [type] =&gt; hidden
                              )
  
                      )
  
              )
  
          [fields] =&gt; Array
              (
              )
  
          [createBy] =&gt; 
          [updateBy] =&gt; 
          [permission] =&gt; 
          [relations] =&gt; Array
              (
              )
  
          [user_id] =&gt; 1
          [user_type] =&gt; 1
          [user_name] =&gt; Admin User
          [user_email] =&gt; admin@localhost.local
          [user_pass] =&gt; $2y$10$sbJV7LZNE2/1RQ5SHyeqWeOIhhU0aXgq7uXQHfID/g9K5tJLENOja
          [user_mobile] =&gt; 
          [user_avatar] =&gt; 
          [user_code] =&gt; 0
          [user_create_by] =&gt; 0
          [user_update_by] =&gt; 0
          [user_create_at] =&gt; 0000-00-00 00:00:00
          [user_update_at] =&gt; 0000-00-00 00:00:00
          [user_status] =&gt; 2
      )
  </code></pre>
  
  <p>)</p>
  
  <p>the below code is where the session is set  </p>
  
  <pre><code>if($auth_driver-&gt;login($input['email'], $input['password'], $input['remember']))
      {
          $userdata = $this-&gt;user-&gt;row(array('user_email'=&gt;$input['email']));
          // if user is not existed, create it
          if (!is_object($userdata)) {
              // create the user and make it active
              $newuser = new User_model;
              $newuser-&gt;user_type     = User_model::TYPE_USER;
              $newuser-&gt;user_name     = $input['email'];
              $newuser-&gt;user_email    = $input['email'];
              $newuser-&gt;user_pass     = $input['password'];
              $newuser-&gt;user_mobile   = '';
              $newuser-&gt;user_avatar   = '';
              $newuser-&gt;user_status   = User_model::STATUS_ACTIVE;
              $newuser-&gt;save();
              // load the user info
              $userdata = $this-&gt;user-&gt;row(array('user_email'=&gt;$input['email']));
          }
      }
  
  
      if(isset($userdata) &amp;&amp; is_object($userdata) &amp;&amp; isset($userdata-&gt;user_id)) {
          // check if the account is active 
          if($userdata-&gt;user_status == User_model::STATUS_ACTIVE) {
              $this-&gt;session-&gt;set_userdata('userdata', $userdata);
              redirect('/User/Dashboard');
          } else {
              unset($userdata);
              set_message('activate_your_account', 'error');
              redirect('/Auth/Activate');
          }
      } else {
          set_message('wrong_email_or_password', 'error');
      }
      redirect('/Auth/Login');
  }
  </code></pre>
  
  <p>I want you to help me access the user_id in the userdata </p>
  
  <p>Thanks in advance </p>