<?php
class Login_model extends CI_Model
{
	private $dt = 'zo_tbl_admin';

	function __construct()
    {
        parent::__construct();
    	$this->load->library('session');
	}

	function checkAuth($email,$password){
		$email    = trim($email);
		$password = trim($password);
		$this->db->select('*');
		$this->db->where('email',$email);
		$this->db->where('password',md5($password));
		$this->db->where('status','1');
		$query = $this->db->get($this->dt);
		$data  = array();
		if($query->num_rows()>0){
			$data = $query->row_array();
			$ses = array(
						'admin_id'   =>	$data['admin_id'],
						'name'       =>	$data['name'],
						'image'      =>	$data['image'],
						'isLoggedIn' =>	TRUE
					);
			$this->session->set_userdata($ses);			
			return $data;
		} else {
			return $data;
		}
	}
	
	public function logout(){
		$this->session->unset_userdata('admin_id');
		$this->session->unset_userdata('name');
		$this->session->unset_userdata('image');
		$this->session->unset_userdata('isLoggedIn');
	}
}
?>