简体   繁体   中英

IF condition to show specific data to the logged in user

I need to separate the view of a specific user from the system to a specific client. For example; The logged in user (user1 - ID_1) can only view the client data (client2 - ID_2). Is it possible to do this in an IF condition as in the example below? (Id_users comes from the users table, and id_clients, from the clients table)

public function view() {
    if ($this-> 'id_users' = '1') {
        data['view'] =  'idclients' = '2';
    }

    $this->data['custom_error'] = '';
    $this->load->model('mapos_model');
    $this->data['result'] = $this->os_model->getById($this->uri->segment(3));
    $this->data['products'] = $this->os_model->getProducts($this->uri->segment(3));
    $this->data['services'] = $this->os_model->getServices($this->uri->segment(3));
    $this->data['emitent'] = $this->mapos_model->getEmitent();

    $this->data['view'] = 'os/viewOs';
    $this->load->view('theme/top', $this->data);
}

you can use session .any place to your project

if($this->session->userdata('session_name')){
   echo "Your specific data";
}
else{
echo "Others Data";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM