Reputation: 129
In the below codeigniter code after i logout i can able to view page but i want not to view page after logout . I placed the controller below.
function logout()
{
$this->session->sess_destroy();
$this->index();
}
Upvotes: 1
Views: 872
Reputation: 286
Hopefully you're using templates for your views and this will be painless but make sure this is in the head of each page you don't want accessible by the back button.
header("Cache-Control: no-store, no-cache, must-revalidate");
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE, NO-STORE, must-revalidate">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT=0>
Just to explain what is happening. The page is loading from your browser cache meaning the browser thinks your user is still logged in. The above lines make the browser revalidate the page on every load and won't load it from it's own cache.
Upvotes: 0
Reputation: 4331
If you are attempting to restrict user from certain page with authentication you can implement some code like this :
if($this->user->logged() == FALSE)
{
redirect('login');
}
Write down this code in your method otherwise you can write this in constructor.As for as i got from your question not from the title of your question.
Upvotes: 0
Reputation: 286
Try this
function logout()
{
$this->session->sess_destroy();
$this->load->helper('url');
redirect('base_url() ,'refresh');
exit;
}
Upvotes: 0
Reputation: 1210
Check in each controller method which loads the page whether the person is logged in or not. If not redirect. you have to do it in each function that loads a view.
Upvotes: 0
Reputation: 2348
You can try this
function logout(){
$this->CI =& get_instance();
$this->CI->session->sess_destroy();
redirect(base_url());
}
Upvotes: 3