<?php

defined('BASEPATH') OR exit('No direct script access allowed');



class Log extends CI_Controller {

    

    public function __construct(){

        parent::__construct();      

        $this->load->model('M_log');

    }

	public function login(){

		$d["username"] = $this->input->post('username');

		$d["password"] = md5($this->input->post('password'));

		$cek = $this->M_log->data_login($d)->num_rows();

		$data = $this->M_log->data_login($d)->row_array();

		if($cek == 1){

			$data['session_status'] = "1";

			$this->session->set_userdata($data);
            $this->M_log->insert_log($data);
			echo json_encode(true);

		}else{

			echo json_encode(false);

		}

    } 

    public function logout(){

        $this->session->sess_destroy();

        redirect(base_url('login.aspx'));

    } 

}

