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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:14:49+00:00 2026-06-03T07:14:49+00:00

I’m making a simple reading canvas app, and I want to be ale to

  • 0

I’m making a simple reading canvas app, and I want to be ale to check if the user has been logged in before loading any of the content/articles. Naturally I have the FB.Init method, and I have a getLoginStatus within it, and it looks like this (I’ve removed my namespace and ID):

    <script> 
    window.fbAsyncInit = function() {       
      FB.init(
      {
        appId   : '[APP ID]', // App ID
        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.authResponse) {
         var oauth_url = 'http://www.facebook.com/dialog/oauth/';
         oauth_url += '?client_id=[APP ID]';
         oauth_url += '&redirect_uri=' + encodeURIComponent('http://apps.facebook.com/[APP NAMESPACE]/');
         oauth_url += '&scope=read_stream,publish_stream,offline_access'
         window.top.location = oauth_url;
         }  
      });   

    };
    // 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>

But it no matter what I do, it loads my HTML content first (my Articles, Divs, Paragrafs, texts…) and redirects after finishing with that.

The script is the head od my HTML. I’ve also tried loading it through a onLoad() method in the body, but that didn’t work either, it still loads some of my HTML content before redirecting.

How can I make it checked if the user is logged in to Facebook (and redirect if he’s not), before loading even a single letter or image of the HTML code?

  • 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-06-03T07:14:50+00:00Added an answer on June 3, 2026 at 7:14 am

    You are using asynchronous loading of the facebook js sdk, and more than that, once you send the output back from the server (being static content or dynamic content) the browser gets the entire content and loads it, there’s no much you can do about that.

    If you want to check if the user is authenticated before then I advice you to use the Server-Side auth flow.
    That way you can know the status before you even return the content to the user, if you discover that he’s not authenticated then the content you send back to him is the redirection content.
    Only when the user comes back authenticated will you send back the canvas content.


    Edit

    If your entire app is static then keep it that way, no need to add php (or any other server side solution) just for server-side authentication.

    I’m not exactly sure why you mind if the page is loaded before the redirect, here are two “solutions”:

    (1) Load a minimized page that has just the fb sdk and methods for checking if the user is logged in or not, if he is not then redirect him.
    If he is logged in then load a script that adds the rest of the content and dynamically add it to the dom.

    (2) In case that you just don’t want the user to see something before he logs in, just make that part hidden with css and when he logs in change it using javasript.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.