Multiple social login using Facebook, twitter, yahoo, gmail in codeigniter

In this tutorial I will explain you how to do Multiple social login using Facebook, twitter, yahoo, gmail in codeigniter Now a day most of the user do not like to do registration. So you can verify the user simply by using social login through Facebook, twitter, yahoo, gmail etc. Social login using codeigniter is very easy you just need to do some simple task. First download the file from GitHub link this.
Now Extract the file and open it

social login in codeigniter

Now open Social-CodeIgniter-for-CodeIgniter3.0.1 and you will see the application folder.

Now download the codeigniter from link

Extract the file and place in the local host and rename with name login. Open the folder and your folder structure will look like this

social login in codeigniter

Now delete the application folder from this folder. Don’t get confused we will copy the application folder in place of this folder from the file we have downloaded from GitHub.

Open Social-CodeIgniter-for-CodeIgniter3.0.1 which you have downloaded from GitHub and you will see the application folder.
social login in codeigniter

social login in codeigniter

Copy this folder in the codeigniter folder in place of the application folder you have deleted.

Now open the file route.php inside the config folder and replace

$route['default_controller'] = 'Welcome';


$route['default_controller'] = 'hauth';

Now run the url http://localhost/login/

You will see your browser like this
social login in codeigniter

Now create the application on Facebook developer page and activate the application. After creating the application your application will look like this. Follow the instruction marked in red. As you are testing on local host App Domains and Site URL must be local host.

login using facebook api

Now open the config folder and and look for the file name hybridauthlib.php Open this file and copy and paste the Facebook App ID and App Secret in the file

login using facebook API in codeigniter
Now you can do login using Facebook into your website. Hope this tutorial Multiple social login using Facebook, twitter, yahoo, gmail in codeigniter will help you. You can create the API for the rest social login and place the App ID and App Secret in the hybridauthlib.php.

  • freddy

    Hi bro thanks for making this library, i have been developing about this issue but hard to applicate with database ? please write some tutorial about databse if you are free, thanks a lot

    • Ricky Negi

      @freddy very soon I will write the tutorial on how to insert the data in the database. Keep reading and support

  • Pingback: Login using Instagram in PHP()

  • Marcelo Diniz

    Very good article, but I have a question, as would my users database, at least one idea, for I have users who can register without any network or for some, such as facebook, twitter or google?

    Thank you

  • Nabeel

    There is an error when i click to logout .. there is no Logout function in the controller

  • Aman Jham

    How to resolve that The server can not find the requested page:??

  • Kareem Japer

    I have Fatal error with Facebook

    Fatal error: Uncaught exception ‘Exception’ with message ‘Authentication failed! Facebook returned an invalid user id.’ in /application/third_party/hybridauth/Hybrid/Auth.php:153 Stack trace: #0 /application/third_party/hybridauth/Hybrid/Auth.php(39): Hybrid_Auth::initialize(Array) #1 /application/libraries/HybridAuthLib.php(14): Hybrid_Auth->__construct(Array) #2 /system/core/Loader.php(1096): HybridAuthLib->__construct(Array) #3 /system/core/Loader.php(976): CI_Loader->_ci_init_class(‘HybridAuthLib’, ”, NULL, NULL) #4 /system/core/Loader.php(217): CI_Loader->_ci_load_class(‘HybridAuthLib’, NULL, NULL) #5 /application/controllers/hauth.php(9): CI_Loader->library(‘HybridAuthLib’) #6 /home/activatio in /application/third_party/hybridauth/Hybrid/Auth.php on line 153

  • Shiv Yadav

    when i have press logout button i got(404 Page Not Found The page you requested was not found.) error
    i have tried many times still i have got this error.

    • Pramod Yewale

      //Add bellowed function to your controller and set logout link to this.

      public function logout($provider)

      $service = $this->hybridauthlib->authenticate($provider);

    • Shiv Yadav

      Thank you.

  • Shiv Yadav

    Hello , can someone help me?
    i need compulsory email id of user when he used social login , i set it also in scope array as bellow.

    “Facebook” => array (
    “enabled” => true,
    “keys” => array ( “id” => “XXXXXXXXXXXX”, “secret” =>”XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX” ),
    ‘scope’ => ’email,user_profile’
    but not working..

    please help

    thanks in advanced.