I've noticed that if a user is logged out of facebook (say they login from another computer or browser) while they are connected to the site then I get an error as follows:

Facebook API exception Session key invalid or no longer valid.
#0 C:\<path_to_drupal>\drupal\sites\all\modules\fb\facebook-platform\php\facebookapi_php5_restlib.php(1056): FacebookRestClient->call_method('facebook.friend...', Array)
#1 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb.module(460): FacebookRestClient->friends_get()
#2 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb_views\fb_views_handler_filter_friends.inc(21): fb_get_friends('423', Object(stdClass))
#3 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(660): fb_views_handler_filter_friends->query()
#4 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(587): view->_build('filter')
...

I realize this bug is probably an uncommon corner case, but I think it can be fixed by updating line 449 in fb.modules to read:

try{
  $fb->api_client->users_getLoggedInUser();
}
catch(Exception $e){
  //TODO: this should forward to login page
  return;
}

BUT I don't know how to forward the user to the fb_connect initialization page! Is there a function I can call that will get this process going? Thanks!

Files: 

Comments

Agreed there should be no error.

About forwarding the user, I'm not sure you want to forward them anywhere. Just treat them as a not logged in user. the code in fb_connect.js should reload the page, thus showing they are not logged in.

Not sure I'm following you on this, are you suggesting that fb_connect.js poll Facebook and reload the page if the session disappears? I'm ok with just treating them as a logged out user, but I'm not clear on how to accomplish this. It seems like I may need to wrap every call the facebook api's with a try catch block... but even if that's the fix, what exactly would go in the catch block?

Actually, I think I understand what you're saying... Typically the js will reload the page immediately after page load, if the fb session has disappeared. So the appropriate action here is to simply return empty content, display it, and allow the js to reload the page to reflect that the user is no longer authenticated. Correct?

Ignoring facebook connect for a moment... Say you're logged into a drupal site. You leave that page in your browser for a long time, during which the drupal cookies expire. Next time you click a link or refresh the page, you'll find yourself logged out. (But until you click, it appears like your logged in). This is common behavior on most websites, not drupal-specific.

Now, with facebook connect... Say you're logged in to faceobok and an DFF-powered site. You log out of facebook. In your other window, the DFF site does not update automatically. When you click a link or refresh a page, then you discover you are not logged in. Again, not drupal-specific, I think most if not all facebook connect sites will behave this way.

I don't think DFF needs to handle this case any differently. Do you?

Hm ok, so I'll just update access args for any page making calls to fb's api. For some reason I wanted more than that, but it does seem to work just fine...

Version:6.x-3.x-dev» 6.x-2.x-dev
Category:bug» support
Status:Active» Fixed

marking as fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

I'm re-opening this issue b/c I don't think the behavior described by Dave Cohen in post #4 is really how things are currently working in DFF.

I just recently installed DFF and enabled the fb_example module since it already has the programming for adding like buttons on node page etc.

When I log in to facebook (while not logged in to my drupal site) If I then go to my facebook app - DFF logs me into the drupal site (so far so good).

However, now when I log OUT of facebook - and go to my drupal site in a separate tab - the drupal site has me still logged in even though I logged out of FB. I can browse arouns the site and it still shows my facebook username etc.

If I click logout - it still does not log me out - I still see the facebook username after logging out.

I suspect it has to do with the facebook javascript but i'm still new to this module so I haven't had time to fully understand the code.

Certainly if one logs out of facebook then the drupal site should not the person logged in.

Version:6.x-2.x-dev» 6.x-3.0-rc4
Category:support» bug
Priority:Normal» Critical

I've included a short screen cast demonstrating what happens with the site I'm working on. I am unable to log out of the drupal side period. I have successfully logged out of FB using the app within FB as demonstrated in the cast, but as you'll see it is clearly not logging me out of the Drupal site. even after I visit the website outside of FB and try to log out it's not happening.

http://screencast.com/t/1G2ixOD04H

Looking forward to hearing back on this.

BTW I'm posting this as I realize that there has been a newly updated version and will reply if things get fixed. Even after updating the issue is still present.

Do either of you guys see javascript errors when clicking logout? use firebug or something like that to check.

JoshuaBud, read the doc recipe for canvas pages. make sure you've made the right changes to settings.php then sync properties on your apps. Make sure you've checked the primary checkbox for your connect app.

Version:6.x-3.0-rc4» 6.x-3.0-rc5

The following errors pop up.

The "fb-root" div has not been created. all.js line 3
all.js:6TypeError: Result of expression 'e.root' [undefined] is not an object. all.js line 6

Line 3 code

if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b<a;b++){var g=d[b];var f=e[g];if(!f){f=(h&&b+1==a)?h:{};e[g]=f;}e=f;}return e;},provide:function(c,b,a){return FB.copy(typeof c=='string'?FB.create(c):c,b,a);},guid:function(){return 'f'+(Math.random()*(1<<30)).toString(16).replace('.','');},log:function(a){if(FB._logging)if(window.Debug&&window.Debug.writeln){window.Debug.writeln(a);}else if(window.console)window.console.log(a);if(FB.Event)FB.Event.fire('fb.log',a);},$:function(a){return document.getElementById(a);}};

line 6

FB.provide('Content',{_root:null,_hiddenRoot:null,_callbacks:{},append:function(a,c){if(!c)if(!FB.Content._root){FB.Content._root=c=FB.$('fb-root');if(!c){FB.log('The "fb-root" div has not been created.');return;}else c.className+=' fb_reset';}else c=FB.Content._root;if(typeof a=='string'){var b=document.createElement('div');c.appendChild(b).innerHTML=a;return b;}else return c.appendChild(a);},appendHidden:function(a){if(!FB.Content._hiddenRoot){var b=document.createElement('div'),c=b.style;c.position='absolute';c.top='-10000px';c.width=c.height=0;FB.Content._hiddenRoot=FB.Content.append(b);}return FB.Content.append(a,FB.Content._hiddenRoot);},insertIframe:function(e){e.id=e.id||FB.guid();e.name=e.name||FB.guid();var a=FB.guid(),f=false,d=false;FB.Content._callbacks[a]=function(){if(f&&!d){d=true;e.onload&&e.onload(e.root.firstChild);}};if(document.attachEvent){var b=('<iframe'+' id="'+e.id+'"'+' name="'+e.name+'"'+(e.title?' title="'+e.title+'"':'')+(e.className?' class="'+e.className+'"':'')+' style="border:none;'+(e.width?'width:'+e.width+'px;':'')+(e.height?'height:'+e.height+'px;':'')+'"'+' src="'+e.url+'"'+' frameborder="0"'+' scrolling="no"'+' allowtransparency="true"'+' onload="FB.Content._callbacks.'+a+'()"'+'></iframe>');e.root.innerHTML='<iframe src="javascript:false"'+' frameborder="0"'+' scrolling="no"'+' style="height:1px"></iframe>';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}});

Ok - so I login to facebook - go to my site's app - which automatically logs me into the site.

Then I log out of facebook.

i go to my site's url

It shows me as logged in with my facebook username

when I click logout firebug says "fb_logout() called without a session"

I have the same issue but it only seems to happen in Safari (I'm on a mac). I get logged off facebook itself and my app page reloads and keeps me logged in, but when I quit and reopen Safari I'm no longer logged in on my app.

On Firefox everything seems to be working perfectly. I get logged off both app and facebook whether I use the facebook logout or my app's logout.

Can anyone reproduce this on www.drupalforfacebook.org or apps.facebook.com/drupalforfacebook ?

Hmm.

Seems like www.drupalfoprfacebook.org is a bit more robust. Here is what I did:

Log into facebook.
go to apps.facebook.com/drupalforfacebook -> this logs me into drupal for facebook
logout out of facebook
go to www.drupalforfacebook.org
I get the "you're connected" header along with my facebook profile pic. BUT
when I refresh the page it correctly detects that I'm logged out and show the connect with faceboopk button.

It's this last part that is not happening on my site. so maybe there is some setting or customization that I am missing?

Sometimes javascript errors like that are because some other module (fb_social?) is initializing facebook's javascript.

StatusFileSize
new231.2 KB

I accessed the Facebook for Drupal page with Safari. When I logout through Facebook the app still shows me being logged in (See attached screengrab). I have to use the logout link to logout from the app.

In Firefox I get logged off both in one shot.

So Dave what should we do to get out from #15 problem. I am also facing this problem on my website.

@ajaykumartak, which release are you using. Some recent changes to .dev release *might* have fixed this, I'm not certain.

@Dave now i m using version 3.x -dev for Drupal 6.x ........ but still i m facing this problem.

Version:6.x-3.0-rc5» 6.x-3.x-dev

Does your application prompt for the offline_access extended permission?

I m also facing this proublem , when i m logout from our Fbconnect site i also logout from facebook.. i m using 3.1

fb connect is working fine instead of drupal for facebook, if you want only connect to facebook ..