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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:47:57+00:00 2026-06-08T00:47:57+00:00

I am using a facebook log in for my web site using facebook php

  • 0

I am using a facebook log in for my web site using facebook php sdk.

What I noticed is the logout link doesn’t do anything. After I logout, the user can still navigate the site. Here is my code in facebook.php:

<?php
    require 'src/facebook.php';
    $facebook = new Facebook(array(
           'appId'  => '*************',
           'secret' => '******************************',
    ));
    $user = $facebook->getUser();
    $loginUrl = $facebook->getLoginUrl();
    echo "<a href='$loginUrl'>login</a>";

    $logoutUrl = $facebook->getLogoutUrl();
    echo $loginUrl; 
    if($user){
        session_start() ; 
        $_SESSION['user_info'] = $user; 
        $_SESSION['user_pro']= $facebook->api('/me');
        print_r($_SESSION);
    }
    else{
        echo 'not logged in '; 
    }

    echo "<a href='example.com/logout.php'>log out </a>"
?>

This code works fine on log in. The log out link should destroy the session. Here is the header of the page:

<?php 
    print_r($_SESSION) ; 
    header('example.com') ; 
?>

The problem with my logout.php page is it doesn’t detect the session at all. I don’t know if this is a facebook api problem or my php problem.

How do you log the user out using the facebook SDK?

  • 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-08T00:47:59+00:00Added an answer on June 8, 2026 at 12:47 am

    You can logout from your site as well as from facebook as follow by providing your site url to next parameter and destroying session

    $token = $facebook->getAccessToken();
    $url = 'https://www.facebook.com/logout.php?next=' . YOUR_SITE_URL .
      '&access_token='.$token;
    session_destroy();
    header('Location: '.$url);
    

    You also have to log them out of your website AND you have to prevent your website from automatically remembering your user and re-logging them in immediately.

    Disable the code that auto-logs in your user and try to logout again. Destroying the session will not prevent your site from creating a brand new valid session for the remembered user.

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

Sidebar

Related Questions

Using the PHP sdk I'm signing users into my site with Facebook log in.
I am using facebook PHP SDK. After the user allows my application, facebook redirects
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl
I'm using Facebook's PHP SDK to log users in to my website, like so:
How can I log a user out from my facebook connect website, without using
I'm using the Facebook C# SDK to allow users to log in to my
using Facebook Javascript SDK (since FBml doesn't work anymore), posting to a wall using
In my Android app, I log in using the Facebook SDK and display posts
I'm using Facebook PHP SDK to implement authorization through Facebook Connect on my website.
I can authenticate Facebook for desktop application using web browser control. But I want

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.