Search code examples
facebook

Facebook PHP SDK couldn't logout


I am using the latest facebook php sdk, but i found the method Facebook::getLogoutUrl( $params=array() ) doesn't work! getUser() always return my userid.


Solution

  • You can specify a redirect URL in your logout function and clear Facebook cookie and session after logout redirection, like:

    Facebook::getLogoutUrl( array( 'next' => 'your_logout_page.php' ) );
    

    and in "your_logout_page.php":

    setcookie('fbs_'.fb_app_id, ', time()-100, '/'); //clear FB cookie
    session_destroy();