Hi all So I have a website to which I have added a facebook login button. the button itself works like a charm. However, I can't figure out how I can check, if the user is now logged in, so I only show the content to logged in users. Dows FB set a cookie upon loggin in, or how can I check for it? I also would like to pull the data about the user from facebook. i'm thinking I need to access the Graph API, but I'm not that proficient in programming, and cant seem to understand how it's done. Can someone please help me? thanks
Thanks for your reply Oddly enough, I can't seem to find any documentation about how to see, if the user has logged in. It's easy enough to implement the login button, but I need to be able to access a cookie or something. Othewise it's no use...
Here's a snippet from a fb application. For websites, procedure is same. Change a few things link canvasurl,fbconnect=1,canvas=0 etc. <?php session_start(); ob_start(); require_once("facebook.php"); // including the SDK $thispage = 'http://example.com/myfbAPP/index.php'; $canvasurl = 'http://apps.facebook.com/myfbAPP/'; $fb = new Facebook(array('appId' => 'APP_ID','secret' => 'APP_SECRET','cookie' => true,)); $perms = 'publish_stream,user_photos'; $user = $fb->getUser(); if(is_null($user) || $user==0){ $loginurl = $fb->getLoginUrl(array('canvas'=>1,'fbconnect'=>0,'display'=>'page','redirect_uri'=>$canvasurl,'scope'=>$perms)); echo"<script type='text/javascript'>top.location=\"$loginurl\";</script>"; exit; } else{ $userinfo = $fb->api("/$user"); echo" <br /> <img src='http://graph.facebook.com/$user/picture/?type=square' alt='' /> <a class='fbxWelcomeBoxName' href='$userinfo[link]'>$userinfo[name]</a> <br/> "; // YOUR POST LOGIN STUFF GOES HERE ?> Code (markup):