<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Session extends CI_Controller {
	
    function __construct() 
    {
        parent::__construct();
    }
    
    public function admin() 
	{
	    $this->session->set_userdata('dev_admin', true);
	        redirect('');
	    
	    
	    $senha = $this->uri->segment(4);
	    if($senha == null)
	    {
	        var_dump('Informe a SENHA');
	    }
	    elseif ($senha == 852456) {
	        $this->session->set_userdata('dev_admin', true);
	        redirect('');
	    }
	    else
	    {
	        var_dump('Senha Invalida');
	    }
	}
    
    
	public function get_last_activity() 
	{
		if($this->input->post())
		{
			$last_activity = $this->session->userdata('timestamp');
			$t = strtotime("+".$this->config->item('sess_expiration')." seconds", $last_activity);
			$date_expire = date("Y-m-d H:i:s", $t);
		    $csrf_renew = array(
                'name' => $this->security->get_csrf_token_name(),
                'hash' => $this->security->get_csrf_hash()
            );
			echo json_encode(array('date_expire' => $date_expire, 'csrf'=>$csrf_renew));
		}
	}
    
}