Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook api does not reload after login

Basically, on my website I've added a login button for facebook, and the login works fine. However, you have to refresh once you've logged in to see that you're logged in. I've looked up the problem and the codes provided did not work.

Here is the code that I'm currently using in attempt to refresh the page after a successful login:

FB.Event.subscribe("auth.login", function(response) {
   window.location.reload();
});

Although that should work, it doesn't; it's not even refreshing the page as specified in the code. Here's the code for the Facebook login button:

 <fb:login-button perms="email,user_likes,user_photos">CONNECT Bla Bla</fb:login-button>

Could anybody please suggest some kind of fix as I've been working on this for many hours and it seems somewhat of an inconvenience for users to reload after a login.

like image 981
Jarrod Avatar asked Nov 30 '25 19:11

Jarrod


2 Answers

Try this code for your FB login button

 <fb:login-button scope="email,user_likes,user_photos"    onlogin='window.location="http://yourdomain.com/yourpage.php";'>Connect with Facebook</fb:login-button> 
like image 96
Abhik Chakraborty Avatar answered Dec 02 '25 08:12

Abhik Chakraborty


For anybody that's still interested in an answer, for this, use the following code: Thanks to @Abhik Chakraborty for the base of the code.

<fb:login-button scope="email,user_likes,user_photos"    onlogin='window.location.reload(true);'>Connect with Facebook</fb:login-button> 

And that will then force your browser to reload the website (like a 'hard' reload).

like image 44
Jarrod Avatar answered Dec 02 '25 08:12

Jarrod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!