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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:36:08+00:00 2026-06-05T17:36:08+00:00

My problem is: if I am already logged in facebook, then it automatically redirect

  • 0

My problem is:
if I am already logged in facebook, then it automatically redirect the page and log in to my site.

What I need is even if I am logged in to facebook, it should stay on the page and after I click on the “facebook login” button then it will log in to my website.

<script>
    // Load the SDK Asynchronously
    (function(d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) { return; }
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    } (document));

    // Init the SDK upon load
    window.fbAsyncInit = function() {
        FB.init({
            appId: 'XXXXXXXXXXX', // App ID
            channelUrl: '//' + window.location.hostname + '/channel', // Path to your     Channel File
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });

        FB.Event.subscribe('auth.login', function(response) {
            if (response.status === 'connected') {
                FB.api('/me', function(me) {
                    if (me.name) {
                        // 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;
                        done1(uid, accessToken, me.email, me.name);
                    }
                })
            }

        });

        FB.Event.subscribe('auth.logout', function(response) {
        });


        // listen for and handle auth.statusChange events
        FB.Event.subscribe('auth.statusChange', function(response) {
            if (response.authResponse) {
                // user has auth'd your app and is logged into Facebook
                FB.api('/me', function(me) {
                    if (me.name) {
                        document.getElementById("authdisplayname").innerHTML = me.name;
                        if (response.status === 'connected') {
                            var uid = response.authResponse.userID;
                            var accessToken = response.authResponse.accessToken;
                            done1(uid, accessToken, me.email, me.name);
                        }
                    }
                })
                document.getElementById('auth-loggedout').style.display = 'none';
                document.getElementById('auth-loggedin').style.display = 'block';
            } else {
                // user has not auth'd your app, or is not logged into Facebook
                document.getElementById('auth-loggedout').style.display = 'block';
                document.getElementById('auth-loggedin').style.display = 'none';
            }
        }); 
        $("#authlogoutlink").click(function() { FB.logout(function() { window.location.reload(); }); });
    }

    function done1(a, b, c, d) {
        document.getElementById("<%= uid.ClientID %>").value = a;
        document.getElementById("<%= token.ClientID %>").value = b;
        window.location = "http://localhost:59019/fgfgf_2008/new_login.aspx?token=" + b + "&email=" + c + "&name=" + d;
    }
</script>

HTML Code:

<div id="fb-root">
</div>

<div>
    <div id="auth-status">
        <div id="auth-loggedout">
            <div class="fb-login-button" onlogin="done();" autologoutlink="true" scope="email,user_checkins">
                Log in with Facebook</div>
        </div>
        <div id="auth-loggedin" style="display: none">
            Hi, <span id="authdisplayname" runat="server"></span>(<a href="#" id="authlogoutlink">logout</a>)
        </div>
    </div>
</div>
  • 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-05T17:36:10+00:00Added an answer on June 5, 2026 at 5:36 pm

    I am not a master on facebook login issue, but after reading your question, it looks like that if the facebook user is logged in to its facebook account, then it also automatically logs into your application. But you want it to take place at the time when the user clicks on the login button, right.

    What you can do is, you can make a “FacebookLogin()” function and you can call that function on a click event.

    Something like:

    On the HTML button

    <div class="fb-login-button" onclick="FacebookLogin()" onlogin="done();" autologoutlink="true" scope="email,user_checkins">
                    Log in with Facebook</div>
    

    I am not very sure for this in your case, but it worked for me, try for once, remove ur all FB.Event.subscribe('auth.login', function(response) function, and use FB.login() function, and then redirect the user information to the page where ever you want. Here I am redirecting it to a Login.aspx page.

    In the javascript function

    function FacebookLogin() {
        FB.login(function(response) {
            if (response.authResponse) {
                window.location = "/Login.aspx?NewFacebookConnect=true&accessToken=" + response.authResponse.accessToken + "&userID=" + response.authResponse.userID;
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've already integrated facebook login in my Android app but my problem is here:-
I need to implement facebook-connect to a website where users already might have their
I got a Problem with the Facebook Login on my page. First I tried
I am trying to use (and this may be my problem already) e.Graphics.CopyFromScreen() in
I read through many of solutions of this problem already, but I still can't
I tried to find a solution to my problem already in google and here
I have the following Problem: I have already opened a JQuery dialog and I
another problem. I have already placed my Jython.jar into what my computer recognizes as
Problem: Applying $(.price).hide(); works to elements already rendered, however, when I load a new
I have already made an algorithm for the problem but it still got a

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.