linus72982 Posted July 18, 2010 Share Posted July 18, 2010 I've looked at it a hundred times and can't figure out what I did wrong. Here's what the page starts with, just a standard start to a page that is using facebook API, this isn't the problem but it gives context: <?php require ('/home/a2027775/public_html/php/facebook.php'); require ("/home/a2027775/public_html/php/ayam_Accounts.php"); $accounts = new Accounts; $facebook = new Facebook(array( 'appId' => 'CENSORED', 'secret' => 'CENSORED', 'cookie' => true, )); $session = $facebook->getSession(); $me = null; if ($session) { try { $uid = $facebook->getUser(); $me = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); } } if ($me) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } ?> Now, usually I can then use "if ($me) {do stuff if they're logged into facebook} else {show page with option to log in}" - it's always worked before, but then I add this code: <?php if ($me) { session_destroy(); session_start(); $_SESSION['uid']=$uid; if (!$accounts->isMerged($uid)) { header('Location: http://MYDOMAIN.com/mergeFB.php'); } elseif (!isset($_SESSION['loggedIn'])) { $accounts->setFBUserIn($uid); } } ?> and something breaks, my initial "if ($me)" always seems to figure true as no matter if I'm logged in to facebook or not, I get redirected to the mergeFB page. Any thoughts? If you need it, there is another script on the page that deals with the Facebook stuff but I don't think it has any bearing on the problem. In any case, here it is: window.fbAsyncInit = function() { FB.init({ appId : '<?php echo $facebook->getAppId(); ?>', session : <?php echo json_encode($session); ?>, status : true, cookie : true, xfbml : true }); FB.Event.subscribe('auth.login', function() { window.location.reload(); }); }; (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/208067-my-if-statement-is-always-true/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.