Codeigniter, Session and Back Button

A few days ago Achmad Solihin said to me that a little bug in Codigniter (CI) at the session part. It happens after logging out and destroying the session, hit the back button, the page content appears again (that should be not). Well, it seems CI bugs or something, but there is a solution in the CI forums; which is just adding the @session_start() function before checking the session validation.

Why using the @ before the session_start() ? It seems that CI already call that function, but somehow it didn't work. If just adding the session_start() it will give some error that states the function already called. So to ignore the error, add the @ characters should fix it.

 

.
.
@session_start();
if ($this->session->userdata('login_state') == TRUE )
{
  echo 'valid session';
} else
{
  redirect( 'some-url' );
}
.
.

Well, hope that helps.. smile

 

Read Comments


Let your comments be the first by filling the form below :)

Add Your Comments



Name*

E-mail*

Website

Your Comment*