title: answered reload session in codeigniter after updating profile pic
body: <p>i have this code its running but i want refresh my session when i update a profile pic the current pic will be change by the new pic i dont know what to do this part <code>$this-&gt;session-&gt;???</code> help would be appreciate</p>
  
  <pre><code>public function upload()
      {
          $config['upload_path'] = './assets/default_image/';
          $config['allowed_types'] = 'gif|jpg|png';
          $config['max_width']  = '1000';
          $config['max_height']  = '1000';
          $config['min_width']  = '768';
          $config['min_height']  = '768';
          $config['max_size'] = '204800';
      $this-&gt;load-&gt;library('upload',$config);
      if(!$this-&gt;upload-&gt;do_upload()){
          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
          $this-&gt;load-&gt;view('funct/upload_image',$error);
  
      }else{
      $data=array('upload_image' =&gt; $this-&gt;upload-&gt;data());
      $id=$this-&gt;input-&gt;post('did');
      $info=$this-&gt;upload-&gt;data();
      $name = array('avatar' =&gt;  $info['file_name']);
      $this-&gt;resize_image($data['upload_image']['full_path'],$data['upload_image']['file_name']);
      $this-&gt;user_model-&gt;get_image($id,$name);
      $this-&gt;session-&gt;set_userdata('avatar',$name);
  
      redirect('site','refreshed');
  
                  }
  }
  </code></pre>
  
  <p>Edit here is the answer my friend helped 
  the solution was that in my session it was arrayed so he did he unset the arrayed loggin he made a new one still in arrayed form and then that is it he
  fix it</p>
  
  <pre><code>public function upload()
  {
      $config['upload_path'] = './assets/default_image/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_width']  = '1000';
      $config['max_height']  = '1000';
      $config['min_width']  = '768';
      $config['min_height']  = '768';
      $config['max_size'] = '204800';
  
      $this-&gt;load-&gt;library('upload',$config);
      if(!$this-&gt;upload-&gt;do_upload()){
          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
          $this-&gt;load-&gt;view('funct/upload_image',$error);
  
      }else{
      $data=array('upload_image' =&gt; $this-&gt;upload-&gt;data());
      $id=$this-&gt;input-&gt;post('did');
      $info=$this-&gt;upload-&gt;data();
      $name = array('avatar' =&gt;  $info['file_name']);
      $this-&gt;resize_image($data['upload_image']['full_path'],$data['upload_image']['file_name']);
      $this-&gt;user_model-&gt;get_image($id,$name);
  
      //new session
       $result = $this-&gt;user_model-&gt;get_new_sess($id);
  
  
              foreach($result as $row)
               {
                $sess_array = array('id' =&gt; $row-&gt;id,
                               'F_name' =&gt; $row-&gt;F_name,
                               'L_name'=&gt;$row-&gt;L_name,
                               'username'=&gt;$row-&gt;username,
                               'email'=&gt;$row-&gt;Email,
                               'avatar'=&gt;$row-&gt;avatar,
                               'date' =&gt;$row-&gt;registered_date,
                               'position'=&gt; $row-&gt;name);
                  $this-&gt;session-&gt;unset_userdata('avatar');
                  $this-&gt;session-&gt;set_userdata('logged_in', $sess_array);
                          }
  
      $this-&gt;session-&gt;set_flashdata('item','Your profile is up-to-date');             
      redirect('accounts/view/'.$id);
                  }
  </code></pre>
  
  <p>here is the edit part</p>