javascript - Facebook Custom Button Implementation Issue -


connect.js

connect.php

i trying create facebook login custom button using facebook sdk. have created , able login via clicking on "continue facebook" button . problem whenever redirects memberpage after clicking on continue facebook button , tries click on "logout" button on memberpage kill session created custom button . redirects me sigin page. within seconds again redirect me memberpage. issue here : redirecting memberpage again , again , not able logout.however, if try login without facebook using provided username , password . able login , logout without issue. above have given links code.

connect.js(contains facebook login , authentication code.)

  function getuserdetails() {         fb.api('/me?fields=id,name,email,birthday,gender,first_name,last_name,verified,hometown', function(response) {                  var data = {                     access_token: fb.getaccesstoken(),                     fb_id: response.id,                     email: response.email,                     name: response.name,                     first_name: response.first_name,                     last_name: response.last_name,                     birthday:response.birthday,                     verified: response.verified,                     hometown:response.hometown.name,                     gender: response.gender                 };                 $.ajax({                     url:'connect.php',                     type: 'post',                     datatype: 'json',                      data:  {user:data}                 });           });      }       function statuschangecallback(response)     {         if (response.status === 'connected') {             $("div.fb-login").hide();             getuserdetails();         } else {             $.ajax({             url:'connect.php',                 type: 'post',                 datatype: 'json',                 data: {                     action: 'logout.php'                 }             });            }     }      function checkloginstate() {         fb.getloginstatus(function(response)         {             statuschangecallback(response);         });     }         fb.login(function(response){            checkloginstate();          },{scope: 'public_profile,email,user_about_me,user_birthday,user_hometown'});       window.fbasyncinit = function() {         fb.init({             appid      : 'xxxxxx',             cookie     : true,             xfbml      : false,             version    : 'v2.6',             status     : true, // check login status             oauth      : true // enable oauth 2.0          });          fb.getloginstatus(function(response) {             statuschangecallback(response);         });     };      (function(d, s, id) {         var js, fjs = d.getelementsbytagname(s)[0];         if(d.getelementbyid(id)) return;         js = d.createelement(s); js.id = id;         js.src = "//connect.facebook.net/en_us/sdk.js";         fjs.parentnode.insertbefore(js, fjs);     }(document, 'script', 'facebook-jssdk')); 

connect.php(the data sending via connect.js goes here , methods gets stored in database , used create session variables.)

logout.php:(whenever user click on logout button given on memberpage.php redirects user page , after destroying sessions redirects user sigin page.)

$session_destroy(); 

signin.php:

<script src="connect.js"></script>  <button onclick="fb.login()">continue facebook</button> 

i got solution.

here "fb.init" function calls everytime automatically when page loaded or refreshed . has function "fb.getloginstatus" pretending destroy session because invoking again , again , new session creating. on basis of signin page checking session variables , getting session variables value after destroying session using logouy making signin page redirect member page. removed fb.getloginstatus function fb.init , site working fine.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -