我已经构建了一个限制登录仅限3个设备的应用程序。 每次使用新设备进行登录时,如果用户具有可用的设备插槽,则会将cookie保存在用户浏览器中。
//we check if the user has available slots
if ($logged_in_user['slots'] > $this->devices_model->count_devices($logged_in_user['id'])) {
//here us the cookie saved
$cookie = array(
'name' => 'kolass_app',
'value' => md5(uniqid($logged_in_user['id'], true)),
'device' => $this->agent->browser() . ' ' . $this->agent->version(),
'expire' => time() + (10 * 365 * 24 * 60 * 60),
);
$this->input->set_cookie($cookie);
$data['user_id'] = $logged_in_user['id'];
$data['device'] = $cookie['device'];
$data['value'] = $cookie['value'];
$this->devices_model->add_device($data);
redirect(base_url());
} else {
$this->session->set_flashdata('error', 'This device is not authorised or you dont have available devices slots.');
redirect(base_url());
}
我的问题是,如果我们保存新设备,我想获得用户确认。