<?php

	defined('BASEPATH') OR exit('No direct script access allowed');
	class Login extends Admin_Controller {

	public function __construct(){
       parent::__construct();
	    $this->load->model('Login_model');
	   /*cash control*/
		$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
		$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
		$this->output->set_header('Pragma: no-cache');
		$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
	}
	
	   //Method for view login page 
		public function index(){
		$this->Login_model->loggedin() == FALSE || redirect('Admin');
		$this->load->view('login/login');	
	   }

	   //Method for varify login information 
	   public function varifyUser(){
        
        $username=$this->input->post('login-username',true);
        $password=$this->input->post('login-password',true);
		$this->Login_model->login($username,$password);
        if($this->Login_model->loggedin() == FALSE){
        $this->session->set_flashdata('error', 'Username Or Password Is Incorrect !');
		redirect('Login','refresh');
		}else{
		redirect('Dashboard');
		}
	   }
	   
	   //Method for logout
	   public function logout(){
	   	$this->Login_model->logout();
	   	redirect('Login');
	   }
	   


   
}