Skip to content

Instantly share code, notes, and snippets.

@tediscript
Created November 24, 2011 04:36
Show Gist options
  • Save tediscript/1390627 to your computer and use it in GitHub Desktop.
Save tediscript/1390627 to your computer and use it in GitHub Desktop.
CodeIgniter Auth Library
<?php
/**
* Description of authlib
*
* @author tediscript
*/
class Authlib {
function __construct() {
$this->CI = get_instance();
$this->CI->load->library('session');
}
public function login($auth_data = array()) {
$this->CI->session->set_userdata('auth_data', $auth_data);
}
public function logout() {
$this->CI->session->unset_userdata('auth_data');
}
public function get_login() {
if (empty($this->CI->userdata('auth_data'))) {
return false;
} else {
return $this->CI->userdata('auth_data');
}
}
public function is_login() {
if (empty($this->CI->userdata('auth_data'))) {
return false;
} else {
return true;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment