我怎樣才能避免被在笨再次單擊瀏覽器的按鈕,當再次登錄?我摧毀德會話時註銷,但是當我回到CLIC它仍然進入管理頁面瀏覽器,點擊瀏覽器的後退按鈕時,它應該留在重定向的頁面,而不是回到管理頁面。這是我在模型和控制器代碼:如何避免在單擊codeigniter中的瀏覽器後退按鈕時再次登錄?
auth_model:
class Auth_model extends CI_Model {
public function login($name, $password){
$password = sha1($password);
$this->db->where('username',$name);
$this->db->where('password',$password);
$query = $this->db->get('auth');
if($query->num_rows()==1){
foreach ($query->result() as $row){
$data = array(
'username'=> $row->username,
'logged_in'=>TRUE
);
}
$this->session->set_userdata($data);
return TRUE;
}
else{
return FALSE;
}
}
public function isLoggedIn(){
header("cache-Control: no-store, no-cache, must-revalidate");
header("cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$is_logged_in = $this->session->userdata('logged_in');
if(!isset($is_logged_in) || $is_logged_in!==TRUE)
{
redirect('/');
exit;
}
}
auth controller:
public function logout(){
$this->session->sess_destroy();
redirect('/' ,'refresh');
exit;
}
user controller
<?php
class User extends CI_Controller {
function __construct()
{
parent::__construct();
$this->template->set_layout('adminLayout.php');
$this->load->model("User_model");
$this->load->Model('Auth_model');
}
function index()
{
$this->Auth_model->isLoggedIn();
$this->template->title('Admin ::');
$this->template->build('admin/index');
}
function user()
{
$this->Auth_model->isLoggedIn();
$this->template->title('user');
$this->template->build('admin/user');
}
?>
您需要提供更多的代碼 – CodeGodie
您還可以使用會議取消設置摧毀了會議,還有一件事之前,如果你使用緩存,那麼它可能可能是您的瀏覽器可能會顯示管理頁面。否則你可以使用呼叫登錄功能,而不是重定向。如:$ this-> login();在控制器 –
我想你說的什麼,但它仍然保持你在哪裏調用管理模板同樣的問題 – Joe