PHP Google Two Factor Authentication With CodeIgniter 3

Codeigniter Laravel php Programming Technology

Today, We want to share with you PHP Google Two Factor Authentication With CodeIgniter 3 Example.In this post we will show you PHP Integrating Two-Factor Authentication with CodeIgniter – google 2 factor authentication new phone, hear for Integrating Google Two-Factor Authentication with CodeIgniter 3 we will give you demo and example for implement.In this post, we will learn about How to Implement Google Two Factor Authentication Login In PHP with CodeIgniter 3 with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

PHP Google Two Factor Authentication With CodeIgniter 3 Example

There are the Following The simple About PHP Google Two Factor Authentication With CodeIgniter 3 Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP CodeIgniter 3 Google Two Factor Authentication Example, so the Google 2-Step Verification(enable two factor authentication gmail) for this example is following below.

Enable two factor authentication gmail

google 2 factor authentication new phone

How To Works For 2 factor authentication php

PHP Google Two Factor Authentication With CodeIgniter 3 Example Tutorials
PHP Google Two Factor Authentication With CodeIgniter 3 Example Tutorials

Google Two-factor Authentication Tutorial for Codeigniter in Simple our PHP Based CodeIgniter Application is a very simple and easy process. The Google two-factor authentication with generated uniq key will help We to secure your Authentication Simple our admin main login panel with very high secure particular time based an extra layer of main protection. Even if any hackers or unauthorized persona got Simple our main username as well as storng password they data can not log in unless they main know Simple our uniq key or retrive Simple our smart mobile or phone which has connected to google Authenticator app.

Therefor let’s step by step start. The simple main phased is simple latest version of the downloading your system Integrating Google Two-Factor Authentication with CodeIgniter 3 from GitHub. It is a called all the Authentication third party libs and all the relavents methods included but since it has main mind our main BSD Based license, so We can We use that freely in Simple our main any commercial web or mobile application. We can simple google authenticator codeigniter Download from here.

And now, We download it then simple all the source code simple copy this main file GoogleAuthenticator.php file to Simple our codeigniter web application/libraries stored on folder.and Then this file open that file in any you best used editor like notepad++ and some change its PHP Based codeigniter class name to like as GoogleAuthenticator.

And then we have our CodeIgniter library. Now use it in Simple our login function like this,

function login(){

		//PHP Google Two Factor Authentication With CodeIgniter 3 Example
        //USER Interface Form validation source codes
        $setting = array(
                'field' => 'uername',
                'label' => 'user Name',
                'rules' => 'trim|required|xss_clean',
                'errors' => array('required' => 'Please Enter Your Username', 'xss_clean' => 'cant inject malicious uniq code')
                'field' => 'password',
                'label' => 'password',
                'rules' => 'trim|required|xss_clean',
                'errors' => array('required' => 'Please Enter Your Password.', 'xss_clean' => 'cant inject malicious uniq code')
                'field' => 'token',
                'label' => 'Google Two-factor token',
                'rules' => 'trim|xss_clean|max_length[6]',
                'errors' => array('required' => 'Please Enter Your Two Factor Code.', 'xss_clean' => 'cant inject malicious uniq code')


        if ($this->form_validation->run() == FALSE) 


            // google authenticator codeigniter 2 factor authentication source codes

            $googleAuthObj = new GoogleAuthenticator();
            $authSecretKey = "JDBC6PLIJDKDSPNM2L" ; //$googleAuthObj->createSecret();
            $oneCode = $this->input->post('token');
            $token = $googleAuthObj->getCode($authSecretKey);
            $googleAuthResults = $googleAuthObj->verifyCode($authSecretKey, $oneCode, 2); // 2 = 2*30sec clock tolerance
	    if (!$googleAuthResults)
                $this->index('Sorry Your GoogleAuthenticator Two-factor token Failed'); // main page index function here simple load signin page view
                // Two-factor Source code if results success and then now We simple steps for Simple our username as well as Simple our password Login Authentication with verification

You can make a google generated a new secure key by your calling below some PHP or CodeIgniter function.


Once We make a simple google key download Google Authenticator from products of the google your play store application and setup install Simple our main unique key.

Important Note :The Google algorithm is time-based. A new unique source code is generated every moments means 30 seconds as well as each simple code is valid for main 90 seconds only. Therefor We must ensure that Simple our mobile or smart phone time based and Simple our server sure time is exactly same otherwise, it source code won’t work.Please Comment below if We stuck or encountered any types of the problem or I am freely free happy to help you.

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Google Two Factor Authentication With CodeIgniter 3 Example.
I would like to have feedback on my blog with details of the 2 factor authentication php.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP file_get_contents() function Example
  2.   Simple Like Dislike Event Handling in AngularJS
  3.   Laravel 6 Join multiple tables Eloquent Examples
  4.   Install Elasticsearch on Debian 10/9/8 Tutorial
  5.   Ng-Repeat Directive using Angular Example
  6.   PHP Google Multi factor authentication Tutorial With Example
  7.   Form Submission With Validation Using Vue.JS and PHP
  8.   Module Controller using Angular Example
  9.   JavaScript Remove Duplicate values from Array
  10.   $digest() Function using Angular Example

Leave a Reply

Your email address will not be published. Required fields are marked *