Login with facebook using PHP ( Demo and Download )

Login with facebook : You can use facebook login in your websites to allow users to login using their facebook account.you don’t need an extra registration and user management for your sites.you can also manage users in your facebook application page. This article explains how to integrate “Facebook login” to your websites using Facebook PHP SDK with an example and demo.

Login with facebook ( Version: 4 – Updated )

Create Facebook APP ID and APP secret .
Step 1 » Goto https://developers.facebook.com/apps/ and Click Add a New App .
» Choose Website
» Choose Name for you App and Click Create New Facebook App ID
» Choose a category for you App and click Create App ID
» Now Click Skip Quick Test
Login with facebook App ID Creation
Step 2 » Under settings, Provide values for App domain ( Eg:www.krizna.com ) and Contact Email and click Add Platform.
Login with facebook domain name
Provide Values for Site URL and Mobile site URl ( Optional )
Login with facebook site name
Step 3 » Now under Status & Review, Click the button to make you App live .
Login with facebook make live

fbconfig.php file overview

Step 4 » Download the Demo package here Login with facebook .
Step 5 » Now open fbconfig.php file and enter your app ID, secret and change domain name .

Step 6 » Finally full code of fbconfig.php file. See the commented lines for more details

logout.php file overview

Logout.php file is used only to destroy facebook session and return back to your home page .
Step 7 » Enter your home page in the code to redirect after logout.

index.php file overview

Step 8 » You can change this file as per your need . Split this file into 2 parts before login and after login.

Finally full code of index.php file .

That’s it . now facebook users can login into your websites using facebook login ID.

Store the User information

» You can store the user info locally . Create a mysql database and import below table structure .

» Open dbconfig.php file and change the DB vlaues.

» functions.php file contains a function to update the user information .

» Uncomment the below lines in fbconfig.php
require 'functions.php'; // Include functions
checkuser($fbid,$fbfullname,$femail); // To update local DB
That’s it .. now you can store the values locally .

Download contains all the configuration files .
Good luck