How to use Ion Auth as a third party in CodeIgniter 3

Ion Auth is a authentication library for CodeIgniter that has a lot of functions, among them:

  • Securely authenticate users in your system
  • Create users account
  • Sort users by groups (members, editors, administrators)
  • Recover password
  • Min/max password length
  • Brute Force Protection
  • Among other things…


They provide a way to effortelssly integrate the library to an existing CodeIgniter application, using the Third Party resource from CodeIgniter.

To integrate Ion Auth as a third party:

  1. Create a new folder in your project: /applications/third_party/ion_auth
  2. Download Ion Auth from GitHub (or use this direct link)
  3. Copy the contents to third_party/ion_auth
  4. There’s a folder called sql, which has a SQL file to create the users, groups and other tables necessary for ion auth to work. Run the queries or import it to your database. (PS: If you have an existing “users” table, don’t do this, because it will drop the users table and create a fresh one!!)
  5. With the database structure set, you can insert this code in your Controllers, to use Ion Auth library: (more about add_package_path here)
  6.         $this->load->add_package_path(APPPATH.'third_party/ion_auth/');


Example code:


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

class Admin extends CI_Controller {

	public function __construct() {


		if (!$this->ion_auth->logged_in()) {
        // Your admin controller functions here   

Ion Auth documentation:

Tag: , , , ,