title: Why whenever i refresh the page, new CI Session is created?
body: <p>I created a simple log in system, and i used CI Sessions for holding some values.<br>
  But CI sessions did't work as expected, it does not retrieve any value.<br>
  I tried to track the problem, and i figured out something:<br>
  Whenever i refresh the page, a new session is created!<br>
  And only 1 session hold my custom variables(<code>is_logged</code>, <code>username</code>).<br>
  Other sessions just hold default data.<br>
   I tried holding the sessions in a database, and still the same problem.<br>
  Is it my encryption key?<br>
  I just used bunch of random letters, because i can't keep it empty.<br>
  This is the controller I tested my sessions on.<br>
  Note:<br>
  I'm using some <code>echo</code>'s here, just for testing.<br>
  Note2:<br>
  I can retrive session variables only if i call it on the same page.  </p>
  
  <pre><code> &lt;?php
  
  class site extends CI_Controller {
  
      function index() {
          if (!$this-&gt;session-&gt;userdata('is_logged')) {
              $data['main_content'] = 'site_view';
              $this-&gt;load-&gt;view('template/all_templates', $data);
          } else {
              echo 'you\'re logged already';
          }
      }
  
      function login() {
          if (!$this-&gt;session-&gt;userdata('is_logged')) {
              $username = $this-&gt;input-&gt;post('username');
              $password = $this-&gt;input-&gt;post('password');
              if ($username &amp;&amp; $password) {
                  if ($this-&gt;site_model-&gt;validate($username, $password)) {
                      $user_data = array('username' =&gt; $username, 'is_logged' =&gt; TRUE);
                      $this-&gt;session-&gt;set_userdata($user_data);
                      echo 'you successfully log in.';
                      redirect('site/index', 'refresh');
                  } else {
                      echo 'cannot login';
                  }
              } else {
                  echo 'username and/or password not set';
              }
          } else {
              echo 'you\'re logged in already!';
          }
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Note:<br>
  This question is related to this one</p>
  
  <p>Edit1:<br>
  I logged in few times, sometimes with no errors.<br>
  After few refreshes/log ins, see sesssion database:</p>
  
  <pre><code>02d6e3521046ffe7df36b07e88624a60    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803371  
  66a9cf3d6b7e0521dcc7e5bd3d5d4ad1    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803380  
  923a78db029ee3e3ae4bf9e09873fcae    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803366  a:3:{s:9:"user_data";s:0:"";s:8:"username";s:4:"aziz";s:9:"is_logged";b:1;}
  99ac075792b7818aadac60d00ca46947    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803367  
  bbe10f3338226c8d83b0ae58d1ca5149    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803343  a:3:{s:9:"user_data";s:0:"";s:8:"username";s:4:"aziz";s:9:"is_logged";b:1;}
  ed6a22ae1d2fd21b6ef66668c2078a11    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803375  
  feb5806176dc8a4f7ed8f30763f65f8b    127.0.0.1   Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (K  1323803380  a:3:{s:9:"user_data";s:0:"";s:8:"username";s:4:"aziz";s:9:"is_logged";b:1;}  
  </code></pre>
  
  <p>As you may notice, some results with user data.  </p>
  
  <p>my validate function :  </p>
  
  <pre><code>function validate($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;num_rows() == 1) {
          return true;
      } else {
          return false;
      }
  }  
  </code></pre>
  
  <p>Note:<br>
  I tested in FF &amp; Chrome.</p>