Issue In Logging In With Facebook

Hi, i am newbi to YII. i am using an extension to connect with facebook. its link is given below.

    $user = Yii::app()->facebook->getUser();

if ($user){


    $facebookUserInfo = Yii::app()->facebook->api('/me?scope=email');

    $facebookUser = Yii::app()->facebook->getUser();

    $data =  $facebookUserInfo;


    echo '<pre>'; print_r($data); echo '</pre>';

} else {

	//echo 'ELSE';

    $data = null;	    

    $this->widget('ext.yii-facebook-opengraph.plugins.LoginButton', array(




i have just write this logic that if user logged in successfully then it should show user’s data array else it should show FB login button.

the problem is, after login it did not show user data. when i refresh page then it shows user data.

please guide me how i can resolve it.