Skip to content

Instantly share code, notes, and snippets.

@buddycore
Created February 28, 2017 21:02
Show Gist options
  • Select an option

  • Save buddycore/eb7ae29bcd777d899b28506857c15796 to your computer and use it in GitHub Desktop.

Select an option

Save buddycore/eb7ae29bcd777d899b28506857c15796 to your computer and use it in GitHub Desktop.
Auth Helper
if(!function_exists('is_logged_in')) :
function is_logged_in() {
$CI =& get_instance();
if($CI->session->userdata('is_logged_in') == FALSE) :
return FALSE;
else :
return TRUE;
endif;
}
function is_logged_in_admin() {
$CI =& get_instance();
if($CI->session->userdata('role') === 'admin') :
return TRUE;
else :
return FALSE;
endif;
}
function get_admin_user_id(){
$CI =& get_instance();
$CI->db->limit(1);
$CI->db->where('role', 'admin');
$CI->db->order_by('id', 'asc');
$query = $CI->db->get('users');
if($query->num_rows() > 0) :
$query = $query->result();
return $query[0]->id;
else :
return FALSE;
endif;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment