Ajinkya
Ajinkya

Reputation: 11

Logout ,Session Expiration

Hi I am developing a website using codeigniter,php that requires secure login, The problem arises when I logout, & firstly I destroy the session but trouble is, when I click back on the browser it is displaying the Login page again.. Thanks for answers in advance

Following is my index function &
website is my controller .

public function index()
{   
    if(logged_in() )
    {
        redirect('/website/dashboard'); 
    }

    else
    {
        redirect('/website/login');
    }


}

code works for me.. But when i logout from site & press back button i am seeing my dashboard again...

my log out function :

public function logout($redirect = false)
{


    $this->CI->session->sess_destroy();
    if($redirect)
    {
        $this->CI->load->helper('url');
        redirect($redirect, 'refresh');
    }
}

Upvotes: 1

Views: 185

Answers (1)

AkshayP
AkshayP

Reputation: 2169

I suggest you to add something like following code to each of your VIEW page

<?php
if($this->session->userdata('session_set')!='true' )
{
     redirect('/website/login');
}?>

Upvotes: 0

Related Questions