title: facebook sdk 4.0 logout php
body: <pre><code>&lt;?php
      /* INCLUSION OF LIBRARY FILEs*/
      require_once( 'lib/Facebook/FacebookSession.php');
      require_once( 'lib/Facebook/FacebookRequest.php' );
      require_once( 'lib/Facebook/FacebookResponse.php' );
      require_once( 'lib/Facebook/FacebookSDKException.php' );
      require_once( 'lib/Facebook/FacebookRequestException.php' );
      require_once( 'lib/Facebook/FacebookRedirectLoginHelper.php');
      require_once( 'lib/Facebook/FacebookAuthorizationException.php' );
      require_once( 'lib/Facebook/GraphObject.php' );
      require_once( 'lib/Facebook/GraphUser.php' );
      require_once( 'lib/Facebook/GraphSessionInfo.php' );
      require_once( 'lib/Facebook/Entities/AccessToken.php');
      require_once( 'lib/Facebook/HttpClients/FacebookCurl.php' );
      require_once( 'lib/Facebook/HttpClients/FacebookHttpable.php');
      require_once( 'lib/Facebook/HttpClients/FacebookCurlHttpClient.php');
  
      /* USE NAMESPACES */
  
      use Facebook\FacebookSession;
      use Facebook\FacebookRedirectLoginHelper;
      use Facebook\FacebookRequest;
      use Facebook\FacebookResponse;
      use Facebook\FacebookSDKException;
      use Facebook\FacebookRequestException;
      use Facebook\FacebookAuthorizationException;
      use Facebook\GraphObject;
      use Facebook\GraphUser;
      use Facebook\GraphSessionInfo;
      use Facebook\FacebookHttpable;
      use Facebook\FacebookCurlHttpClient;
      use Facebook\FacebookCurl;
  
      /*PROCESS*/
  
      //1.Stat Session
       session_start();
  
      //check if users wants to logout
       if(isset($_REQUEST['logout'])){
          unset($_SESSION['fb_token']);
       }
  
      //2.Use app id,secret and redirect url 
       $app_id = '';
       $app_secret = '';
       $redirect_url= 'domain.php';
  
      //3.Initialize application, create helper object and get fb sess
       FacebookSession::setDefaultApplication($app_id,$app_secret);
       $helper = new FacebookRedirectLoginHelper($redirect_url);
       $sess = $helper-&gt;getSessionFromRedirect();
  
      //check if facebook session exists
      if(isset($_SESSION['fb_token'])){
          $sess = new FacebookSession($_SESSION['fb_token']);
      }
  
      //logout
      $logout = '';
  
      //4. if fb sess exists echo name 
          if(isset($sess)){
              //store the token in the php session
              $_SESSION['fb_token']=$sess-&gt;getToken();
              //create request object,execute and capture response
              $request = new FacebookRequest($sess,'GET','/me');
              // from response get graph object
              $response = $request-&gt;execute();
              $graph = $response-&gt;getGraphObject(GraphUser::classname());
              // use graph object methods to get user details
              $name = $graph-&gt;getName();
              $id = $graph-&gt;getId();
              $image = 'https://graph.facebook.com/'.$id.'/picture?width=300';
              $email = $graph-&gt;getProperty('email');
              $gender =$graph-&gt;getProperty('gender');
              echo "hi $name &lt;br&gt;";
              echo "your email is $email &lt;br&gt;&lt;Br&gt;";
              echo "your $gender";
              // echo "&lt;img src='$image' /&gt;&lt;br&gt;&lt;br&gt;";
              echo "&lt;a href='".$logout."'&gt;&lt;button&gt;Logout&lt;/button&gt;&lt;/a&gt;";
              $_SESSION['name'] = $name;
              $_SESSION['email'] = $email;
              $_SESSION['gender'] = $gender;
          }else{
              //else echo login
              echo '&lt;a href="'.$helper-&gt;getLoginUrl(array('email')).'" &gt;Login with facebook&lt;/a&gt;';}
  ?&gt;
  </code></pre>
  
  <p>i follow this facebook sdk web it work fine in log in , but how i going to make log out work for this script ? i try to kill the session and cookie but the data still store in facebook session and i cant log out. can anyone give me a help here?</p>