<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm using a rescue. &nbsp;I tried advancing this discussion a couple weeks ago - the problem&nbsp;is that to really *know* that the session is valid, you have to try using&nbsp;it (i.e., hit the facebook rest server with a request). &nbsp;I think it's a waste to<div>constantly ping the facebook server just to make sure you don't get an invalid session error when you're not expecting it, especially given that this scenario will be low-frequency with respect to total requests.<br><div><br></div><div>So here's what I did in facebooker/rails/controller.rb:</div><div><br></div><div><div>module Facebooker</div><div>&nbsp;&nbsp;module Rails</div><div>&nbsp;&nbsp; &nbsp;module Controller</div><div>&nbsp;&nbsp;&nbsp; &nbsp; def self.included(controller)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;controller.rescue_from Facebooker::Session::SessionExpired, :with => :facebook_session_expired &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;end</div><div>&nbsp;&nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;def facebook_session_expired</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clear_fb_cookies!</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clear_facebook_session_information</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flash[:error] = "Your facebook session has expired."</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;redirect_to root_url</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div></div><div><br></div><div>I'm hesitant to add this to facebooker because i'm not convinced everyone will want to do it this way, and</div><div>it probably means adding another parameter like "expired_session_url" so that this exception handling</div><div>works out of the box (since not everyone will redirect to root_url).</div><div><br></div><div>&nbsp;- kevin</div><div><br></div><div><br><div><div><div>On Feb 1, 2009, at 12:51 PM, Adeel Ahmad wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">This may be related to Aaron's question on Jan. 30. However in my case I doing Facebook Connect using Facebooker for my site.<br>Following the Facebook Connect tutorial it does create a session and show the user as logged in. For now I have the same 'fb' controller just to demo log in.<br> However if the user logs out at <a href="http://facebook.com" target="_blank">facebook.com</a> and then refreshes fb/index on my site, I get "Session key invalid or no longer valid" on the line that outputs @<a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a>. Just FYI if I output @facebook_session.user.to_s it does give me the uid.<br> If you look at the stack trace below you'll notice that it passes through a number of actions that test for existence and validity of the session. It has a problem in the Error class of parser.rb. I would think it should catch the problem a lot earlier than in parser.rb.<br> Any thoughts on how to troubleshoot and/or workaround this? I'm on Rails 2.1.1.<br><br>========================================<br>&nbsp;Facebooker::Session::SessionExpired in Fb#index<br><br>Showing fb/index.html.erb where line #10 raised:<br> <br>Session key invalid or no longer valid<br><br>Extracted source (around line #10):<br><br>7: &lt;%= fb_login_button%><br>8: <br>9: &lt;% if facebook_session %><br>10:&nbsp;&nbsp; &lt;h2>You are logged in as &lt;%= <a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a> %>&lt;/h2><br> 11: &lt;% else %><br>12:&nbsp;&nbsp; &lt;h2>You are not logged in!&lt;/h2><br>13: &lt;% end %><br><br>vendor/plugins/facebooker/lib/facebooker/parser.rb:487:in `process'<br>vendor/plugins/facebooker/lib/facebooker/parser.rb:15:in `parse'<br> vendor/plugins/facebooker/lib/facebooker/service.rb:20:in `post'<br>vendor/plugins/facebooker/lib/facebooker/session.rb:473:in `post_without_logging'<br>vendor/plugins/facebooker/lib/facebooker/session.rb:484:in `post'<br> vendor/plugins/facebooker/lib/facebooker/logging.rb:27:in `log_fb_api'<br>vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'<br>vendor/plugins/facebooker/lib/facebooker/logging.rb:27:in `log_fb_api'<br> vendor/plugins/facebooker/lib/facebooker/session.rb:483:in `post'<br>vendor/plugins/facebooker/lib/facebooker/models/user.rb:120:in `populate'<br>vendor/plugins/facebooker/lib/facebooker/model.rb:35:in `name'<br> app/views/fb/index.html.erb:10:in `_run_erb_47app47views47fb47index46html46erb'<br><br clear="all"><br>-- <br><font color="#888888">- Adeel<br><br><br> </font></div><br> _______________________________________________<br>Facebooker-talk mailing list<br><a href="mailto:Facebooker-talk@rubyforge.org">Facebooker-talk@rubyforge.org</a><br>http://rubyforge.org/mailman/listinfo/facebooker-talk<br></blockquote></div><br></div></div></div></body></html>