views:

595

answers:

3
//file test.php

require_once 'config.php';

if($fb->get_loggedin_user())
{

        // step1 do something

        //step2 expire session    
}
else
{
    //FB coonect login button
}

I need to expire session after i am done with the step1 in the above code. But $facebook->get_loggedin_user() always returns a user id and never goes into else part.

I tried $fb->clear_cookie_state(); $fb->api_client->user=0; $fb->api_client->session_key=null; $fb->logout('index.php');

Nothing is seems to be working. please help. How can i make him log out??

A: 

I had a good answer on this before...maybe this will help you out.

http://stackoverflow.com/questions/1386557/how-to-log-out-users-using-facebook-connect-in-php-and-zend/1386749#1386749

Typeoneerror
+1  A: 

There is currently no way to do this through Facebook's "RESTful API" which is what the PHP client library interfaces with. You can, however, accomplish this with Facebook's "JavaScript API" which includes the functions FB.Connect.logout() and FB.Connect.logoutAndRedirect(url). Calling either of these functions on any Facebook canvas page or FB Connect page will expire the user's current Facebook session.

Dustin Fineout
A: 

@Dustin Fineout

FB.Connect.logoutAndRedirect("fb.php");

when i call the above it shows a confirmation dialog before logs me out. How can i modify the code so it doesnt show the dialog box. Is there a way around??

chris
You should post this as a comment not an additional answer. No, there is no way to avoid the popup. You are logging the user out of Facebook, I think they have the right to be notified. Otherwise it would be extremely easy to force users to log out of Facebook. Of course its always possible that you could identify the elements in the popup, identify the data it is sending to FB servers in the background, and force it to hide while you mimic the request it sends, thereby effectively eliminating the popup. You're definitely on your own with that one :)
Dustin Fineout
You should also use 1 account instead of having multiples.
Dustin Fineout

related questions