Facebook PHP SDK getUser() API returns user ID even after logout.

I implemented  login and logout using facebook PHP sdk.  And encountered an issue and after searched for answer and found few answers in this link and tried all of them.

Finally calling $facebook->destroySession() worked for me.

So here is how I implemented the logout for facebook.

<?php


$facebook = new Facebook(array('appId' => '1232313212....', 'secret' => '123....'));


 $params = array( 'next' => 'http://..../logout.php' );
?>
<img src="fb.png" width=20 height=20 /><a href="<?php echo $facebook->getLogoutUrl($params); ?>" >Logout</a></td>


And then in logout.php file I added this code.



$facebook = new Facebook(array('appId' => '1232313212....', 'secret' => '123....'));


$facebook->destroySession();

This trick worked for me.