title: How to store how many times user logged in?
body: <p><strong>Model</strong></p>
  
  <pre><code>function Updateno($user,$data){
         $this-&gt;db-&gt;where('username', $user);  
          $this-&gt;db-&gt;update('user', $data);
      }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>//user login function
      function Ulogin(){
  
          if($this-&gt;session-&gt;userdata('user'))
          {
               $data['user'] = $this-&gt;session-&gt;userdata('user');
              $this-&gt;load-&gt;view("User/choosecategory",$data);
          }
          else
          {        
          $data = array(
          'username' =&gt;$this-&gt;input-&gt;post('username'),
          'password' =&gt;$this-&gt;input-&gt;post('password'),
          );
          $this-&gt;form_validation-&gt;set_rules('username','UserName','required');
          $this-&gt;form_validation-&gt;set_rules('password','Password','required');
          if($this-&gt;form_validation-&gt;run()==false)
              {
              $this-&gt;load-&gt;view('User/login');
              }
          else
              {
              if($this-&gt;user_model-&gt;userlogin($data)==false)
              {
                  $data['error'] = '&lt;div class="alert alert-danger text-danger"&gt;Please Provide Valid Username/Password!&lt;/div&gt;';
              $this-&gt;load-&gt;view('User/login',$data);
              }
              else
              {
                 $this-&gt;session-&gt;set_userdata('user',$data['username']);
                  $data['user'] = $this-&gt;session-&gt;userdata('user');
                  $counter = array(
          'logged_in' =&gt;'logged_in'+1
          ); 
          $this-&gt;user_model-&gt;Updateno($this-&gt;session-&gt;userdata('user'),$counter);
                 $this-&gt;load-&gt;view("User/choosecategory",$data);
              }
              }
          }
      }
  </code></pre>
  
  <p><strong>I want whenever user login successfully my logged_in cloumn value increase by 1 but in this code  the value of logged_in column always to 1,plz help me anyone here</strong></p>