CAFPE Docs
  • Class

Classes

  • Article_model
  • Articles
  • Auth
  • Auth_controller
  • Bcrypt
  • Hierarchical_controllers
  • Ion_auth
  • Ion_auth_model
  • MY_Controller
  • MY_Lang
  • MY_Model
  • Pages
  • Private_pages
  • Public_controller
  • Seeder
  • Slug
  • User_sessions
  • Users

Functions

  • action_result
  • actions_widget
  • admin_area_buttons
  • base64_current_url_encode
  • base64_url_decode
  • base64_url_encode
  • current_lang
  • jscript_tag
  • lang_switcher
  • logged_in
  • redirect_lang
  • site_url_lang
  • style_tag
 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();
    }

    /**
    * Maps to:
    *    - site_url + admin/login
    */
    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());
            }
        }
    }

    /**
    * Maps to:
    *    - site_url + user_sessions/delete/$url
    *
    * @param string $url base64 encoded referer URL
    */
    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();
            // Regenerate session: Fix for a ion_auth bug
            session_start();
            $this->session->sess_regenerate(TRUE);
            $this->status('ok', true, $this->ion_auth->messages());
        }

        redirect($url);
    }
}
CAFPE Docs API documentation generated by ApiGen