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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:52:15+00:00 2026-05-15T23:52:15+00:00

well I’m new to the facebook api stuff, and just recently someone told me

  • 0

well I’m new to the facebook api stuff, and just recently someone told me I was using the old api.

So now, I can’t seem to figure out how to check if the user is logged into my site with the new api.

all I really have is

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({appId: '(appid)', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function(response) {
    if (response.session) {
      // A user has logged in, and a new cookie has been saved
    } else {
      // The user has logged out, and the cookie has been cleared
    }
  });
</script>

and a login button.

If anyone could show me how to check if someones logged in, (or is that it right there?) because I’d like it to change the login button located in a div called

<div id="fbuser">

to welcome the user.

Or even if you can point me towards some useful tutorials, that would be great!

Thanks

  • 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-15T23:52:15+00:00Added an answer on May 15, 2026 at 11:52 pm

    Here is an example where fbLoginStatus() function will be automatically called when user logs in/logs out, so you can decide which div to display there.

    <body>
    <div id="fb-root"></div>
    <script>
      function fbLoginStatus(response) {
         if( response.status === 'connected' ) {
            //user is logged in, display profile div
         } else {
            //user is not logged in, display guest div
         }
      }
      window.fbAsyncInit = function() {
        FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
        FB.getLoginStatus(fbLoginStatus);
        FB.Event.subscribe('auth.statusChange', fbLoginStatus);
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
    

    Now if you need to check if user is logged in right now (for example on button click):

    if(FB.getSession() != null) {
       //logged user id: FB.getSession().uid
    } else {
      //user is not logged in
    }
    

    Sorry, don’t know any good tutorials.

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

Sidebar

Related Questions

Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well, I got problem here with opengl ES stuff (just started to learn about
Well, can they? Like jQuery using a fadeIn function for something on a C++
Well the problem is that I was using code like this: new Date().toJSON().slice(0, 10)
Well I can start the thread when I press togglebutton to ON and it
Well, i took a break from RoR for studies, now I am back, I
well. i was use Reactive Extensions (Rx) package async Request,Before you can start writing
well I'm trying to create a great playlist of music, only using a sigle
Well, that might be a strange question, and maybe just because I'm not familiar
well I havn't really ever using jquery to grab data from a server.. and

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.