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 7078365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:32:20+00:00 2026-05-28T06:32:20+00:00

<div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : ‘MY_APP_ID’, status : true,

  • 0
<div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'MY_APP_ID',
                status     : true,
                cookie     : true,
                xfbml      : true
            });

            FB.Event.subscribe('auth.login', function(response) {
               $.ajax({
                    url: "http://example.com/fbconnect",
                    success: function(){
                     window.location.reload();
        }
                 });
            });
        };
        (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>


<div class="fb-login-button" data-perms="email,user_birthday,user_hometown,user_location">Login with Facebook</div>

It’s working with only two cases:

  1. when a user is NOT logged in and log in to facebook it triggers.
  2. when a user is logged in but didn’t authorize the app yet it triggers.

the third scenario which is not working is when a user is logged in and He is already authorized the app the FB.Event.subscribe('auth.login') won’t trigger !!!

  • 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-28T06:32:20+00:00Added an answer on May 28, 2026 at 6:32 am

    I encountered the same thing as you and I found a function, “getLoginStatus”, that might be of interest for you.

    When the user is already logged in and has granted your app all the permissions, then there is no need to log in again and therefore the event won’t be triggered.

    However, if the response of the “getLoginStatus” is “connected” you can do the stuff you want to do when the user is already logged in and has granted your app all the permissions.

    The complete script might look something like this:

    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'APPID', // App ID
          channelUrl : 'CHANNEL_URL', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true  // parse XFBML
        });
    
        FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
            // the user is logged in and connected to your
            // app, and response.authResponse supplies
            // the user's ID, a valid access token, a signed
            // request, and the time the access token 
            // and signed request each expire
            var uid = response.authResponse.userID;
            var accessToken = response.authResponse.accessToken;
            FB.api('/me', function(response) {
              if (response.name != undefined ) {
                console.log("Welcome, " + response.name);
              }         
            });
          } else if (response.status === 'not_authorized') {
            // the user is logged in to Facebook, 
            // but not connected to the app
          } else {
            // the user isn't even logged in to Facebook.
          }
        });        
    
        // Additional initialization code here
    
      };
    
      // Load the SDK Asynchronously
      (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>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: <script> function del(a){ alert(a); alert($("#"+a).html()); alert($("#td").html()); alert($("#div").html()); } </script> <td
My HTML: <div id="parent"> <div id="child">cx</div> </div> When I use jQuery $('#parent').mouseout(function(){ //something here
In my App I have the following: $("#displayPanel div").live("click", function(){ $(this).css({'background-color' : 'pink', 'font-weight'
I'm trying to write a "blinds" function that would close a DIV in a
I know I can do this: $("#my_div").live("click", function() { alert("My Div was clicked"); }
I need to have a for loop inside my jQuery. Example: for(i=0;i<counter;i++) { $("div"+i+"").click(function(){//some
I have got an HTML snippet similar to: <div id="root"> <div id="A" attrib_2="bar"></div> <div
'<div id="'+div_id+'" class="widget" style="height:60px;width:110px">\n\ <div class="widget-head ui-widget-header" style="cursor:move;height:20px;width:130px">'+ '<span id="'+span_id+'" style="float:right; cursor:pointer" class="dialog_link ui-icon
<div> <div class="left"> <div align="center" class="node"> <div class="nodeText"> <h2 >test</h2> </div> <div class="node"> <h2>test</h2>
How can I horizontally center a <div> within another <div> using CSS? <div id="outer">

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.