title: Codeigniter, redirect to previous page when back button browser is click
body: <p>I want to be when the back button on the browser is clicked. system will redirect to previous page or to a specific page.</p>
  
  <p>I've made a function to check the login session like this</p>
  
  <pre><code>public function cekAuth(){
          /* Mengecek login session
           */
          $sesi = $this-&gt;ci-&gt;session-&gt;userdata('isLogin_'.project);
          $key = $this-&gt;ci-&gt;uri-&gt;segment('1');
  
          if ($sesi == TRUE &amp;&amp; $key == "access") {
              redirect('dashboard/home'); 
              exit();
          } else if($sesi == FALSE) {
              redirect('access');
              exit();
          }
  
      }
  </code></pre>
  
  <p>if the login session is TRUE and the user accesses the login page will be redirected to the dashboard. This has been successfully. </p>
  
  <p>but when I logout always redirected to the dashboard and not to the login page.</p>
  
  <p><strong>LOGOUT:</strong></p>
  
  <pre><code>function logout(){
          $this-&gt;session-&gt;sess_destroy(); 
          $this-&gt;session-&gt;set_userdata('isLogin_'.project , FALSE);
          redirect('access');
      }
  </code></pre>
  
  <p>Can you help me? :)</p>