 <?php
  function is_logged_akun()
  {
    $ci = get_instance();
    $user=$ci->db->get_where('register', ['email' => $ci->session->userdata('pin')])->row_array();
    if (!$ci->session->userdata('pin')) {
      redirect('Authentication');
    }else {
      $role_id = $ci->session->userdata('roles_user');
      $menu = $ci->uri->segment(1);
      $queryMenu = $ci->db->get_where('user_menu', ['menu' => $menu])->row_array();
      $menu_id = $queryMenu['id'];
      $queryAcsesMenu = $ci->db->get_where('user_access_menu', ['role_id' => $role_id, 'menu_id' => $menu_id]);
      if ($queryAcsesMenu->num_rows() < 1) {
        redirect('Authentication/blocked');
      }
    }
  }
  ?>