IF条件向登录用户显示特定数据

时间:2017-05-26 17:51:38

标签: php codeigniter

我需要将特定用户的视图从系统分离到特定客户端。例如;登录用户(user1-ID_1)只能查看客户端数据(client2-ID_2)。是否可以在IF条件下执行此操作,如下例所示? (Id_users来自users表,id_clients来自clients表)

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);
}

1 个答案:

答案 0 :(得分:0)

你可以在你的项目中使用session .any place

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