 <?php
  function is_logged_in()
  {
    $ci = get_instance();
    if (!$ci->session->userdata('email')) {
      redirect('Auth');
    } else {
      $role_id = $ci->session->userdata('role_id');
      // cek apakah akses di tutup atau tidak
      $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('Auth/blocked');
      }
    }
  }
  ?>