Session still exist after facebook logout in my application
hi i am using facebook graph api
for invite friends in my codeigniter
application . if i have already logged in to facebook the following screeen is shown
if i am not logged in the page redirects to facebook login page , after suceesfuliy login redirects back to above page . every thing works fine . but the problem is
1) i log in to facebook .
2) i run my application and get the list of friends to invite (above view) .
3)then i log out from facebook .
4)then refresh (F5) my friends invite page .
exeption occurs ,
part of the exception
Error:FacebookApiException Object
(
[result:protected] => Array
(
[error] => Array
(
[message] => Error validating access token: The session is invalid because the user logged out.
[type] => OAuthException
)
)
[message:protected] => Error validating access token: The session is invalid because the user logged out.
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => C:\xampp\htdocs\elephanti\application\frontend\libraries\connections\facebook.php
[line:protected] => 530
[trace:Exception:private] => Array
my code is
public function invite_friends()
{
$fbconfig = array(
'appId' => $this->co_config_items['fb_appid'],
'secret' => $this->co_config_items['fb_secret'],
'cookie' => true,
'domain' => $this->ci->config->item('domain')
);
$this->ci->load->library('connections/facebook', $fbconfig);
$facebook = new Facebook($fbconfig);
$session = $facebook->getSession();
if (!isset($session)) {
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0
));
echo "<script type='text/javascript'>top.location.href = '$url';</script>";
} else {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$updated = date("l, F j, Y", strtotime($me['updated_time']));
} catch (FacebookApiException $e) {
echo "Error:" . print_r($e, true);
}
}
$data=array('fb_appid'=>$this->co_config_items['fb_appid']);
return $data;
}
exception prints from the
} catch (FacebookApiException $e) {
echo "Error:" . print_r($e, true);
}
block
the thing is in the if else condition the else part is working , but there shouldn't be a session when i logged out from the facebook . but the session has not cleared , i var_dump the sessions in the first and second time .
before log out
array(7) {
["session_key"]=>
string(46) "2.AQC0otQQWydT6w0l.3600.1317193200.0-770398599"
["uid"]=>
string(9) "770398599"
["expires"]=>
int(1317193200)
["secret"]=>
string(24) "E9oNYQCuQdggyp_pJyLnqA__"
["base_domain"]=>
string(9) "localhost"
["acces开发者_高级运维s_token"]=>
string(90) "140577549320080|2.AQC0otQQWydT6w0l.3600.1317193200.0-770398599|5ZoDt4wTt16ve0fgaj8m_X70ojw"
["sig"]=>
string(32) "74a283a7cd2f4d62bb7739deaf65affc"
}
after logout and refresh one time
array(7) {
["access_token"]=>
string(90) "140577549320080|2.AQC0otQQWydT6w0l.3600.1317193200.1-770398599|C84xhtx_dnakmf-7oCZlb07FQL8"
["base_domain"]=>
string(9) "localhost"
["expires"]=>
string(10) "1317193200"
["secret"]=>
string(24) "E9oNYQCuQdggyp_pJyLnqA__"
["session_key"]=>
string(46) "2.AQC0otQQWydT6w0l.3600.1317193200.1-770398599"
["sig"]=>
string(32) "6eedc49e4957708a551c4155ff8f57a6"
["uid"]=>
string(9) "770398599"
}
in the second refresh the session
is NULL
and redirects to the login page and works correct , why is session not clearing in the first time , please help .
UPDATE
after session
is NULL
i print the session
and addede a die
, and logged in to facebook again ;
$session = $facebook->getSession();
print_r($session); die ;the thing is every time now gives NULL
, so i think a place after
$session = $facebook->getSession();
session is creating , i think that's why i get the correct result in the second
time , from where the session is changing ??
i searched and saw similar questions but could not get help. please help ..............
Try adding a listener for when the user logs out;
FB.subscribe('auth.logout', function(response){
// Do something to let your program know that the user is now logged out.
});
And/or, add your own facebook logout to your site with FB.logout(). This should clear your website/s fb session as well as log them out of facebook.com.
精彩评论