Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:40:32+00:00 2026-05-27T21:40:32+00:00

I am using fb connect using js. This is my code: <script> window.fbAsyncInit =

  • 0

I am using fb connect using js. This is my code:

<script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'xxxxxxxxxxxxxxxx',
        status     : true, 
        cookie     : true,
        xfbml      : true,
        oauth      : true
      });

      FB.Event.subscribe('auth.login', function(response) {
        obj=response.authResponse;
        token=obj.accessToken;
        setCookie("access_token_fb", token, '2');

        window.location.reload();
      },true);
    };
    (function(d){
       var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       d.getElementsByTagName('head')[0].appendChild(js);
     }(document));
  </script>

for login I am using:

 <div class="fb-login-button" scope="email,user_checkins"  >Login with Facebook</div>

‘auth.login’ in subscribe function has a response handler it is only being called when user click on fb button and not already logged into FB, enter his/her email address and password in fb window . While if a user is already logged in facebook then fb dialog open and close. It doesnot then pass control to response hander. I read somewhere that force=”true” enable it to detect status change and call call back function. But I don’t know where to add force ture. I think it should be in login div. Is it true or is there some other approach?

thanks for you time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:40:33+00:00Added an answer on May 27, 2026 at 9:40 pm

    Method 1:

    Though I believe that DMCS has given a correct solution to the problem, here is another way to approach. Use FB.login method with a custom login link.

    <script>
    window.fbAsyncInit = function() {
        FB.init({
            appId: 'YOUR-APP-ID',
            status: true,
            cookie: true,
            xfbml: true,
            oauth: true
        });
    };
    
    function facebookLogin() {
        FB.login(function(response) {
            if (response.authResponse) {
                console.log('Authenticated!');
                // location.reload(); //or do whatever you want
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        },
        {
            scope: 'email,user_checkins'
        });
    }
    
    (function(d) {
        var js,
        id = 'facebook-jssdk';
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement('script');
        js.id = id;
        js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
    } (document));
    </script>
    

    Body markup:

    <div id='fb-root></div><!-- required for SDK initialization -->
    <a id='fb-login' href='#' onclick='facebookLogin()'>Login with Facebook</a>
    

    When you click on the button, it will run the callback function inside FB.login.

    Method 2:

    Alternatively, using FB login button plugin, you can subscribe to auth.statusChange and check for the status of the user in response.

    FB.Event.subscribe('auth.statusChange', function(response) {
      // check for status in the response
    });
    

    Note if you are using fb login button plugin, and the user is already logged in and connected to the app, no login button is shown (read it in the documentation here)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On the front-end, I've initialised FB and login using: window.fbAsyncInit = function () {
Using this code on the client side: <script src=//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js></script> <script src=http://cdn.socket.io/stable/socket.io.js></script> <script type=text/javascript> $(document).ready(function
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
I'm gleaning from this question [ Facebook Connect Won't Validate that using Facebook Connect
I am using SSIS to connect to a legecy mainframe database and this allows
`I have fetched all the pages of users using manage_page permission, using this code
I use the javascript to get some data from facebook using javascript sdk: window.fbAsyncInit
I am using Facebook connect and JS client library to retrieve my photos in
I am using Facebook Connect for sharing something on my appliction. So I want
I'm using Facebook Connect's Comments Box ( http://wiki.developers.facebook.com/index.php/Comments_Box ) to handle comments on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.