title: How to set userdata in a session in the model of my login function
body: <p>When a user logs in they are directed to my <code>log in</code> function -- Here is my partially working code. I commented out the parts that I need help with.</p>
  <h1>model</h1>
  <pre><code>    if ($query-&gt;num_rows() == 1)
      { 
          return $query-&gt;row()-&gt;f_name;
      }   
          
      else {
          return false;
      }
  
  }
  </code></pre>
  <h1>controller</h1>
  <pre><code>    if($this-&gt;form_validation-&gt;run()) {
      $f_name = $this-&gt;model_users-&gt;can_log_in();
          $data = array(
              'email' =&gt; $this-&gt;input-&gt;post('email'),
              'is_logged_in' =&gt; 1,
              'name' =&gt; $f_name
              );
              
          $this-&gt;session-&gt;set_userdata($data);
          
          redirect('account_dashboard');  
  </code></pre>
  <p>The user's name is in the database table with their email/pw. I want to get the users <code>f_name</code> and set it in the session when they log in since the session is a global var.</p>
  <h1>view</h1>
  <p>my header shows their name:</p>
  <pre><code>echo $this-&gt;session-&gt;userdata('name'); 
  </code></pre>
  <p>How do I get db_values from the table and pass them along to the session?</p>