Step 1:
Download the latest codeigniter and configure into your localhost.Check once after completing the configuration.
http://localhost/codeigniter

Step 2:
Next download the facebook sdk from below URL : https://github.com/facebook/facebook-php-sdk and unzip the folder.
Find ”Src” folder. Open src folder there you will find three files which are
1)    base_facebook.php
2)    facebook.php
3)    fb_ca_chain_bundle.crt

Step 3:
Copy the files and paste after opening codeigniter folder, then go to the application folder and next go to the libraries folder
codeigniter->application->libraries, paste these files and change the name of the file from “facebook.php” to “Facebook.php”.

Step 4:
Next go to codeigniter folder and create one file name as “.htaccess”
Paste this code

“RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]”

Step5:
Create login controller go to
Codeignator->application->controllers
File name “login.php”

<?php
class login extends CI_Controller {
public function __construct(){
parent::__construct();
parse_str($_SERVER['QUERY_STRING'],$_REQUEST);
$this->load->library('Facebook', array("appId"=>"you app id", "secret"=>"app secret key"));
$this->user = $this->facebook->getUser();
}
public function index() {
if($this->user) {
try{
$user_profile = $this->facebook->api('/me');
echo $user_profile['email'];
echo "<pre>"; print_r($user_profile);
}catch(FacebookApiException $e){
print_r($e);
$user = null;
}
}
if($this->user){
$logout = $this->facebook->getLogouturl(array("next"=>base_url()."login/logout"));
echo "<a href='$logout'>Logout</a>";
}else
{
$data['url'] = $login = $this->facebook->getLoginUrl(array("scope"=>"email"));
$this->load->view('login', $data);
}
}
public function logout() {
session_destroy();
redirect(base_url().'login');
}
}
?>

Step6:
Create login view,go to
Codeignator->application->views
File name “login.php”

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<a href="<?php echo $url; ?>">Click here to login</a>
</body>
</html>
Step 7:

Successfully completed facebook login in codeigniter