我正在使用CodeIgniter。
登录会员后,点击退出后,点击返回按钮,仍然可以查看会员页面。
问题 有谁知道,如果用户已经登出,即使点击后退按钮也无法访问会员页面?
请在下面查看我的代码..
谢谢..
class Site extends CI_Controller{
function index()
{
if(!isset($this->session->userdata['is_loggged_in']))
$this->login();
else
$this->_template();
}
function login()
{
$data['main_content'] = 'login_form';
$data['page_title'] = 'Login - php';
$this->load->view('include/template' , $data);
}
function validate()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username' , 'Username' , 'trim|required' );
$this->form_validation->set_rules('password' , 'Password' , 'trim|required' );
if($this->form_validation->run() == FALSE)
{
$this->login();
}
else
{
$this->load->model('member_model' , 'member');
$query = $this->member->checklogin();
//login successful , make sure no duplicate entry during registration
if($query->num_rows() == 1)
{
$data = array(
'is_loggged_in' => TRUE ,
'username' => $this->input->post('username'),
);
$this->session->set_userdata($data);
$this->_template();
}
else
{
$data = array(
'main_content' => 'login_form' ,
'page_title' => 'Error login' ,
'page_error' => 'Invalid Username or password. '
);
$this->load->view('include/template' , $data);
}
}
}
function _template()
{
$data = array(
'main_content' => 'include/default_inc',
'page_title' => 'Welcome home ran'
);
$this->load->view('include/template' , $data);
}
function logout()
{
$this->session->sess_destroy();
redirect('site/login');
exit;
}
}
/* end of controller site */