I am creating a website using codeigniter where I require 3 login options (Google+, Facebook & Direct Registration).
I am able to achieve this independently; however I am not too sure how to combine to 3 into one controller and start the session.
Here is the controller code for Facebook Login:
public function login()
{
$this->load->model('master/user_model','User');
$this->load->library('session');
$this->load->library('facebook');
$user = $this->facebook->getUser();
if ($user) {
try {
$data['user_profile'] = $this->facebook->api('/me');
$aData['user_profile'] = $this->User->insert_fbuser($data['user_profile']);
$this->session->set_userdata($aData);
} catch (FacebookApiException $e) {
$user = null;
}
}else {
$this->facebook->destroySession();
}
if ($user) {
$aData['logout_url'] = site_url('logout'); // Logs off application
// OR
// Logs off FB!
// $data['logout_url'] = $this->facebook->getLogoutUrl();
} else {
$aData['login_url'] = $this->facebook->getLoginUrl(array(
'redirect_uri' => site_url('login'),
'scope' => array("email") // permissions here
));
}
//$data1 = array_merge($aData, $data);
$this->load->view(__CLASS__.'/index',$aData);
}
Thanks for your time.
Regards, Utpal