<?php
/**
 * Created by PhpStorm.
 * User: carlosgarcia
 * Date: 01/12/16
 * Time: 16:41
 */

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

class Login extends CI_Controller {

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

    public function index(){
        $this->load->view('login');
    }

    public function entrar(){
        $this->load->model('login_model');
        if( $this->login_model->login($_POST['username'], $_POST['password']) ){
            $this->session->set_userdata( 'user_logeado', $_POST['username'] );
            $this->load->view('welcome_message');
        }
        //echo "funcion de login, username: " . $_POST['username'] . ", password: " . $_POST['password'];
    }

    public function logout_ci(){
        $this->session->sess_destroy();
        redirect( base_url() . 'index.php/login' );
    }

}
?>