0

I am developing some services for our users that will facilitate some actions on our website...

I am implementing oAuth 2.0 and the connection with a FB app works ok... but I would like to redo the testing... so for this I would need to disconnect the FB app/FB session from our website... so I can retest the connect...

is there a simple way to do it? I tried FB.logout(); but that did log me out from FB too and it didn't actually disconnect the app from the site....

any advice? Is the only way to delete all cookies and sessions? which cookies to delete?

DS_web_developer
  • 3,622
  • 13
  • 52
  • 83

1 Answers1

0

Haven't tried it but this should (theoretically) work.

<?php
$_SESSION['state'] = $_SESSION['code'] = $_SESSION['access_token'] = $_SESSION['user_id'] = '';
$_REQUEST['state'] = $_REQUEST['code'] = $_REQUEST['access_token'] = $_REQUEST['user_id'] = '';
?>
0xAli
  • 1,059
  • 10
  • 22
  • Ok, I prepended your code to the example.php I got downloading facebook php SDK... and it is not working... when refreshing, I still got the user array full + Even if it would severe the connection with FB, when I would be clicking on connect button I would be connected instantly, without going to the oAuth dialog again (confirming permissions) – DS_web_developer May 10 '12 at 08:52
  • b4 that, the $_SESSION and $_REQUEST gives me an empty array, maybe I need to clean $_COOKIE too – DS_web_developer May 10 '12 at 08:54
  • That's weird, Can you try the build-in function `clearAllPersistentData()` like `$facebook->clearPersistentData();` (But it should do the same as my original code). – 0xAli May 10 '12 at 08:57
  • The FB PHP SDK uses _SESSION not _COOKIE, try the code above, or `unset($_SESSION['code']);` manually. – 0xAli May 10 '12 at 08:59
  • FB.init({ appId: 'getAppID() ?>', cookie: true, xfbml: true, oauth: true }); I will try the clearAll ..... – DS_web_developer May 10 '12 at 09:00
  • Fatal error: Call to protected method Facebook::clearPersistentData() – DS_web_developer May 10 '12 at 09:01
  • Right, I double checked it's a protected function, you can change that to public in facebook.php, – 0xAli May 10 '12 at 09:04
  • [fbsr_12891XXXXXXX] is the cookie value... guess I just unsert this key – DS_web_developer May 10 '12 at 09:04
  • nope, then I get an error about variable $key in facebook.php – DS_web_developer May 10 '12 at 09:06
  • Ok check this http://stackoverflow.com/questions/4265844/delete-facebook-session-cookie-from-my-application-on-users-logout#10009477 – 0xAli May 10 '12 at 09:07
  • Not working as expected.... I get disconnectred for a bit then automatically redirecred back in a loop.... if I then remove the code (you suggested me to add) I am somehow connecrted again :S – DS_web_developer May 10 '12 at 09:19
  • I am sorry i couldn't help ;( – 0xAli May 10 '12 at 09:27