'Ask for user confirmation before run function in Codeigniter
I have built an application which restricts the login to only 3 devices. Each time a new device is used for login a cookie is saved on the user browser if they have available devices slots.
//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());
}
My issue is that I want to get the user confirmation if we save the new device or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
