title: Logout in codeigniter
body: <p>I am trying to design a login/logout page in codeigniter framework.My problem is that when I logout of the web-page I am getting redirected to a login page.
  When I go back I am getting a page which says:</p>
  
  <blockquote>
    <p>Document Expired</p>
  
  <pre><code>This document is no longer available.
  </code></pre>
  </blockquote>
  
  <p>But when I refresh this page I am getting logged into the system again (o.O)</p>
  
  <p>The following codes contain my constructor and logout functionalities. Please help me to design a perfect login logout page </p>
  
  <pre><code>function __construct()
  {
      parent::__construct(); 
  
      $this-&gt;load-&gt;model('user_model');    
  
      $this-&gt;output-&gt;set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
          $this-&gt;output-&gt;set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
          $this-&gt;output-&gt;set_header('Pragma: no-cache');
          $this-&gt;output-&gt;set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    
  }
  
  function logout()
  {
      $newdata = array(
                  'user_name'  =&gt;'',
                  'user_email' =&gt; '',
                  'logged_in' =&gt; FALSE,
                 );
  
       $this-&gt;session-&gt;unset_userdata($newdata);
       $this-&gt;session-&gt;sess_destroy();
  
       redirect('default_controller','refresh');
  }
  </code></pre>
  
  <p>I tried find proper logout method but I am not able to.</p>