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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:56:15+00:00 2026-06-16T13:56:15+00:00

I am working on website, in which i want integrate the facebook login with

  • 0

I am working on website, in which i want integrate the facebook login with my website login system. I have integrated facebook-php-sdk in code. Login functionality work fine. Below are the points that I have issue…

  1. Once logged out and click on login the facebook login screen not open.
  2. Once logged out and refresh the page, the login deatils is displaying again. And login button disappears.
  3. If the above two points will solved then how to maintain login session through out the website?

For above 2 points I have used the below code.

    require 'src/facebook.php';

    $facebook = new Facebook(array(
      'appId'  => YOUR_APP_ID,
      'secret' => SECRET_KEY,
    ));

    session_start();



    if($_REQUEST['msg'] == 'logout'){
        setcookie('fbsr_'.$facebook->getAppId(), '', (time() - 3600), '/', 'domain.com');
        $sts = $facebook->destroySession();         
        session_destroy();
        header("Location: index.php");
        //echo '<meta http-equiv="refresh" content="2;url=index.php">';
    } 

    $userId = $facebook->getUser();
    if ($userId && !isset($_SESSION['fbdata'])) {
        $_SESSION['fbdata'] = array("userid" => $userId);       
    }

<?php if ($userId) {
        $userInfo = $facebook->api('/' + $userId); ?>
        Welcome <?= $userInfo['name'] ?>
    <?php } else { ?>
        <div id="fb-root"></div>
        <fb:login-button></fb:login-button>
    <?php } ?>
        <script type="text/javascript">
            window.fbAsyncInit = function() {
                FB.init({
                    appId      : '<?= YOUR_APP_ID ?>',
                    status     : true, 
                    cookie     : true,
                    xfbml      : true,
                    oauth      : true,
                });

                FB.Event.subscribe('auth.login', function(response) {
                    //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>
        <br />
        <br />
        <a href="<?php echo $_SERVER['PHP_SELF']."?msg=logout"; ?>">Logout</a>
  • 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-16T13:56:17+00:00Added an answer on June 16, 2026 at 1:56 pm

    I found the answer on my questions below.
    1.Once logged out and click on login the facebook login screen not open.

    Facebook cookies was not deleted or we can say was not removed from starage. For this I have used this below javascript

        
        function removeCookie(  name, path, domain) {
    
            if ( getCookie( name ) )
    
            {
    
                document.cookie = name + '=' + ( ( path ) ? ';path=' + path : '') + ( ( domain ) ? ';domain=' + domain : '' ) + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    
            }
    
        }
    

    It works for me.

    2.Once logged out and refresh the page, the login deatils is displaying again. And login button disappears.

    The same reason as above question.

    3.If the above two points will solved then how to maintain login session through out the website?

    Maintain the fb id in session and when request coming for logout remove cookie and destroy the session.

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

Sidebar

Related Questions

I am working on a website which needs to be responsive. I want to
I am working on a website which needs to work across multiple browsers unfortunately
I am working on a website on which we have use parallax effect. In
I've integrated my website with Facebook Connect, authorization/single-sign on all working great. Now im
I have a website,which is currently designed & tested to work only on firefox.If
I'm new in php, now I'm working on a website in which there is
i have a working web form asp.net website build in asp.net 3.5. i want
I want to have a feature for my website which can print the page
I am working on website in which i want to copy the file from
I've been working on a website which contains alot of links. I want to

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.