title: after login display client first name in the top of my header page in codeigniter
body: <p>i have registration page after user register goes to login page,i want to display a user first name in the top pf my header page when we click username i want a dropdown logout after click on logout user shuold be logout..</p>
  
  <pre><code>here is my controller code:
  
  public function login()
   {
         $data['error'] ="Invalid Login";
         $this-&gt;load-&gt;view('auth/header');
             if($this-&gt;input-&gt;post())
               {
                $user = $this-&gt;UserModel-&gt;login($this-&gt;input-&gt;post());
                 if(count($user)&gt;0)
                      {
                       $array = array(
                               'client_id' =&gt; $user['client_id'],
                               'first_name' =&gt; $user['first_name'],
                               'client_type_id'=&gt;$user['client_type_id'],
                               'email' =&gt; $user['email'],
                               'password' =&gt; $user['password'],
                   );
                  $this-&gt;session-&gt;set_userdata('userdata',$array);
  
      if($user['client_id'] == $user['client_id'])
      {
          redirect(base_url('dashboard/dashboard'));
      } 
  }
  else
  {
   $data["error_message"]="Invalid User Name and Password combination";
  }
  </code></pre>
  
  <p>logout</p>
  
  <pre><code>function logout()
  {
      $this-&gt;session-&gt;unset_userdata(userdata);
      $this-&gt;session-&gt;sess_destroy();
    redirect('Auth/login','refresh');
  }
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;a href="javascript:;" data-toggle="dropdown" class="right_color"&gt;
              &lt;?php
               echo $this-&gt;session-&gt;userdata('userdata');
              ?&gt;
              &lt;!-- &lt;img src="&lt;?php echo base_url();?&gt;images/admin.jpg" alt="admin-pic"&gt;--&gt;
              &lt;/a&gt;
  </code></pre>
  
  <p><li>&nbsp;&nbsp;Logout</li></p>