i am using facebook javascript SDK for login button in my website it is working properly but i am missing in two use cases
- whenever facebook cookie is available it is redirecting from index.php to event.php page even though i am firing FB.login() function on-click event.
- when user clicks on logout button on my site i am redirecting it index.php, after loading the index.php page it is again redirecting to event.php page
here is my code in index.php
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '375834632488230', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('auth.login', function(response) {
window.location="http://mysite.com/event.php";
});
function doLogin(){
console.log("clicked on fb");
FB.login(function(response) {
if (response.session) {
FB.api('/me?fields=email,location,name,first_name,last_name,picture',
function (response) { });
}
} , {scope:'email'});
}
</script>
<a href="#" id="fblogin" class="signinfacebook" onclick="doLogin()">Sign in with
Facebook</a>
answering my own question
Remove this code :
This should not be used in this context.
Then include this line in
FB.Login()function :i think this should work fine