how do you logout the user from your site in facebook api, while still keeping the user logged into facebook with cakephp? (I found the answer so wanted to share with everyone).
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I figured this one out just now, after reading CakePHP facebook integration logout issue with CakePHP-Facebook-Plugin.
Basically, although in the demos with webtechnick’s examples, he puts the “Facebook.Connect” component in the AppController, if you want the selective logout piece, the Best place to put it is in reality within the actual controllers that you want to use it in. That or leave it in AppController and pass
noAuth=> trueinto the Facebook.Connect component.Either way, whichever way you choose, you set up one controller (facebook_controller.php?) to handle the facebook logins, and set its component with the noauth set to false (which is default, meaning DO authenticate [read connect.php to understand this]). That way, you have total control over when the users are logged into the site, and you can ACTUALLY log them out (with the regular
redirect($this->Auth->logout()) without having the connect component immediately log them back in on redirect. Here is an implementation below:Let me give you an idea:
app_controller.php
users_controller.php:
your “facebook_controller.php”:
class FacebookaController extends AppController {
…
// i dont personally like to have his piece create my user so:
var $components = array(‘Facebook.Connect’ => array(‘createUser’=>false));
…
now your users/login.ctp file:
And that should be pretty much it. I hope this helps someone reading this who still needs the help.