1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<?php defined('BASEPATH') or exit('No direct script access allowed');
class User_sessions extends Public_controller
{
public function __construct()
{
parent ::__construct();
}
public function create()
{
$this->load->library('form_validation');
$this->load->helper('form');
$this->form_validation->set_rules('username', lang('username'), 'trim|required');
$this->form_validation->set_rules('password', lang('password'), 'required');
if ($this->form_validation->run() === true) {
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('username'), $this->input->post('password'), $remember)) {
redirect_lang('admin/dashboard');
} else {
$this->status('error', false, $this->ion_auth->errors());
}
}
}
public function delete($url = '')
{
$url = $url ? base64_url_decode($url) : site_url_lang('admin/login');
if($this->ion_auth->logged_in()){
$this->ion_auth->logout();
session_start();
$this->session->sess_regenerate(TRUE);
$this->status('ok', true, $this->ion_auth->messages());
}
redirect($url);
}
}