Why doesn't my page get refreshed after login in to facebook?

4.5k Views Asked by At

I have been trying add facebook login to my page. I have facebook login button placed on my page using following script:

    <script src="http://connect.facebook.net/en_US/all.js">
    </script>
    <script>
        FB.init({ 
            appId:'<?php echo APP_ID;?>', cookie:true, 
            status:true, xfbml:true 
        });
    </script>
    <fb:login-button perms="email,user_checkins">
        Login with Facebook
    </fb:login-button>

It shows the login button too. while clicking it opens the login screen of facebook too.

after making successfull login the popup box just closes without refreshing the parent page.

what am i missing?

2

There are 2 best solutions below

3
ifaour On BEST ANSWER

You are not asking the page to refresh after a successful login:

// whenever the user logs in, we refresh the page
FB.Event.subscribe('auth.login', function() {
  window.location.reload();
});

See the PHP-SDK example for more information.

0
Doron Segal On

Two Great Solution

  1. // whenever the user logs in, we refresh the page

    FB.Event.subscribe('auth.login', function() {
      window.location.reload();
    });`
    
  2. <fb:login-button onlogin="LoginFunction()" perms="email,user_likes,user_photos">CONNECT Bla Bla</fb:login-button>

When the user Login we call the function LoginFunction() and then we can do whatever such as refresh or redirect the user.