There are two problems:
The first problem is even if you are clearing your session, the page is accessed by cache stored.
So you have to clear cache or don't save cache.
For that right below code in your __construct function.
$this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
$this->output->set_header('Pragma: no-cache');
After doing this step even if you are going to previous page, where you are redirecting after login, then
You can check on that authenticated page if the user has been logged in or not.If he is not logged in he will not ab;e to go on that page.
Example:
public function after_log_in()
{
if(!empty($SESSION['username'] && $SESSION['os_logged_in'] == true))
{
$this->load->view('clienview');
}
else
{
echo "You are not logged in!";
}
}
So, after log out when you will press the back button it will check whether the user is logged in or not. If you are not logged in, it will show error to you.