我在CI 1.7.3 App中使用Tank Auth進行用戶管理。一切工作正常,但我試圖設置一個flash_message
當用戶註銷時顯示。問題是$this->tank_auth->logout();
函數會破壞會話。我已經修改了坦克驗證庫的註銷功能看起來像:銷燬會話但保留Flashdata
function logout() {
$this->delete_autologin();
// See http://codeigniter.com/forums/viewreply/662369/ as the reason for the next line
$user_session_data = array('user_id' => '', 'username' => '', 'status' => '');
$this->ci->session->set_userdata($user_session_data);
$this->ci->session->unset_userdata($user_session_data);
}
這是以前
function logout()
{
$this->delete_autologin();
// See http://codeigniter.com/forums/viewreply/662369/ as the reason for the next line
$this->ci->session->set_userdata(array('user_id' => '', 'username' => '', 'status' => ''));
$this->ci->session->sess_destroy();
}
在我的控制器我有
function logout(){
if ($this->tank_auth->is_logged_in()) { // logged in
$this->session->set_flashdata('status_message', $this->lang->line('auth_message_logged_out'));
$this->tank_auth->logout();
redirect('');
}
}
如果我刪除$this->tank_auth->logout();
函數消息顯示罰款。我敢肯定,這是一個簡單的會話問題
感謝您的提示! – dennisbot 2013-07-13 13:29:21