 <p>Here is my solution, hope will help.. :D</p> <p>in your model.. i copy paste code bellow but i change a little..</p> <pre><code>function login ($username, $password) { $this-&gt;db-&gt;where('username' , $username); $this-&gt;db-&gt;where('password', $password); $query = $this-&gt;db-&gt;get('users'); if ($query-&gt;result())//if any record { $rows = $query-&gt;row(); $data = array( 'user_name' =&gt; $rows-&gt;username, 'logged_in' =&gt; TRUE, 'validated' =&gt; true ); $this-&gt;session-&gt;set_userdata($data); return true; } else { return false; } } </code></pre> <p>delete your session_start() in controller,, and then in your application/config/autoload.php</p> <p>in this $autoload['libraries'] = array(); => add session like this $autoload['libraries'] = array('session');</p> <p>Thankyou.. :D</p>