我的票务系统处于活动状态。我想要的是,当用户从chrome登录时,如果他再次尝试从firefox登录而又未从chrome登录,那么chrome帐户将自动退出。
这是我的控制器代码:-
public function loginSubmit() {
if($this->session->userdata('is_logged_in')==true){
$sessionData = $this->session->all_userdata();
$userId = $sessionData['id'];
redirect('auth/welcome');
}
else{
$userId = $this->input->post('id');
$u_data = array (
'id' => $userId,
'is_logged_in' => TRUE
);
$this->session->set_userdata($u_data);
$sessionId = session_id();
$this->auth_model->setSession($userId,$sessionId);
redirect('auth/welcome');
$this->login();
}
}
这是我的模型代码:-
public function setSession($userId, $sessionId) {
$data1 = array(
'id' => $userId
);
$oldSessionId = $this->db->select("session_id")
->where($data1)
->get("client_sign_up")
->row('session_id');
print_r($oldSessionId);
$data = array(
'id' => $oldSessionId
);
$this->db->where('id',$data)
->delete('ci_sessions',$u_data);
$this->db->where('id', $userId)
->update('client_sign_up', array('session_id' => $sessionId));
}