I am using cakephp 2.1 and using facebook plugin from https://github.com/webtechnick/CakePHP-Facebook-Plugin
I am using facebook login helper as below
$this->facebook->login(array('redirect' => 'facebook_login', 'label' => 'sign in via facebook', 'id' => 'fb-login')).
and logout helper as below
$this->Facebook->logout(array('redirect' => array('controller' => 'users', 'action' => 'logout'), 'label' => 'Logout')).
In logout action I have written this code.
$this->Auth->logout();
$this->redirect(Controller::referer());
But proble is when new user come and login, its showing old logged user data. So please help me to figure it out.
$this->Auth->logout(); $this->redirect(Controller::referer());
to
$this->redirect($this->Auth->logout()):
To delete cookies you need to set the exact same cookie (domain, path, name) but with an expiration that has passed - when read by the client this will cause the cookie to not be sent with the next request.
check this url https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L132
I've used webtechnick facebook plugin in my apps several times, and logging in and out never worked the way I wanted. So now I am developing my own plugin, which uses server-side connect and can be treated as an Auth object inside CakePHP..
It's as easy as $this->Auth->login()
and $this->Auth->logout()
You can check it out here: http://marianofino.github.com/Facebook-Plugin-for-CakePHP/