Note that you can also add it in your application.rb<div><br></div><div><div>rescue_from Facebooker::Session::SessionExpired, :with =&gt; :facebook_session_expired</div><div><br></div><br>Pierre Valade<br>+33.6.89.04.15.30<br>
<a href="http://www.tiiptop.com">www.tiiptop.com</a><br>
<br><br><div class="gmail_quote">On Sun, Feb 1, 2009 at 10:36 PM, Adeel Ahmad <span dir="ltr">&lt;<a href="mailto:adeel@proletariandesign.com">adeel@proletariandesign.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Funny I just realized that as your email popped up. Thanks again.<br><font color="#888888"><br clear="all">- Adeel</font><div><div></div><div class="Wj3C7c"><br><br><br><div class="gmail_quote">On Sun, Feb 1, 2009 at 1:32 PM, kevin lochner <span dir="ltr">&lt;<a href="mailto:klochner@gmail.com" target="_blank">klochner@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div>it&#39;s only going to catch the exception in your controller, so make sure you<div>
load any needed data from facebook in the controller (rather than leaving</div><div>it to the view - e.g., &lt;%= <a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a> %&gt;</div><div>

<div></div><div><div><br><div><div>On Feb 1, 2009, at 4:26 PM, Adeel Ahmad wrote:</div><br><blockquote type="cite">Thanks, this looks like it should do well for now. However it&#39;s not catching the exception... must be some other config I have wrong. Odd.<br>

<br>module Facebooker<br>&nbsp; module Rails<br>&nbsp;&nbsp;&nbsp; module Controller<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; include Facebooker::Rails::ProfilePublisherExtensions<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def self.included(controller)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.extend(ClassMethods)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.before_filter :set_adapter<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.before_filter :set_fbml_format<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.helper_attr :facebook_session_parameters<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.helper_method :request_comes_from_facebook?<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controller.rescue_from Facebooker::Session::SessionExpired, :with =&gt; :facebook_session_expired  <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def facebook_session_expired<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clear_fb_cookies!<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clear_facebook_session_information<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flash[:error] = &quot;Your facebook session has expired.&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirect_to root_url<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br><br clear="all">- Adeel<br> <br><br> <br><br><div class="gmail_quote">On Sun, Feb 1, 2009 at 11:09 AM, kevin lochner <span dir="ltr">&lt;<a href="mailto:klochner@gmail.com" target="_blank">klochner@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"> <div>I&#39;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&#39;s a waste to<div>

 constantly ping the facebook server just to make sure you don&#39;t get an invalid session error when you&#39;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&#39;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 =&gt; :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] = &quot;Your facebook session has expired.&quot;</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&#39;m hesitant to add this to facebooker because i&#39;m not convinced everyone will want to do it this way, and</div><div>it probably means adding another parameter like &quot;expired_session_url&quot; 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><div></div><div><div>On Feb 1, 2009, at 12:51 PM, Adeel Ahmad wrote:</div>

 <br></div></div><blockquote type="cite"><div><div></div><div><div class="gmail_quote">This may be related to Aaron&#39;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 &#39;fb&#39; 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 &quot;Session key invalid or no longer valid&quot; 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&#39;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&#39;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%&gt;<br>8: <br>9: &lt;% if facebook_session %&gt;<br>10:&nbsp;&nbsp; &lt;h2&gt;You are logged in as &lt;%= <a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a> %&gt;&lt;/h2&gt;<br>

 11: &lt;% else %&gt;<br>12:&nbsp;&nbsp; &lt;h2&gt;You are not logged in!&lt;/h2&gt;<br>13: &lt;% end %&gt;<br><br>vendor/plugins/facebooker/lib/facebooker/parser.rb:487:in `process&#39;<br>vendor/plugins/facebooker/lib/facebooker/parser.rb:15:in `parse&#39;<br>

 vendor/plugins/facebooker/lib/facebooker/service.rb:20:in `post&#39;<br>vendor/plugins/facebooker/lib/facebooker/session.rb:473:in `post_without_logging&#39;<br>vendor/plugins/facebooker/lib/facebooker/session.rb:484:in `post&#39;<br>

 vendor/plugins/facebooker/lib/facebooker/logging.rb:27:in `log_fb_api&#39;<br>vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime&#39;<br>vendor/plugins/facebooker/lib/facebooker/logging.rb:27:in `log_fb_api&#39;<br>

 vendor/plugins/facebooker/lib/facebooker/session.rb:483:in `post&#39;<br>vendor/plugins/facebooker/lib/facebooker/models/user.rb:120:in `populate&#39;<br>vendor/plugins/facebooker/lib/facebooker/model.rb:35:in `name&#39;<br>

 app/views/fb/index.html.erb:10:in `_run_erb_47app47views47fb47index46html46erb&#39;<br><br clear="all"><br>-- <br><font color="#888888">- Adeel<br><br><br> </font></div><br></div></div> _______________________________________________<br>

 Facebooker-talk mailing list<br><a href="mailto:Facebooker-talk@rubyforge.org" target="_blank">Facebooker-talk@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/facebooker-talk" target="_blank">http://rubyforge.org/mailman/listinfo/facebooker-talk</a><br>

 </blockquote></div><br></div></div></div></div></blockquote></div><br></blockquote></div><br></div></div></div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Facebooker-talk mailing list<br>
<a href="mailto:Facebooker-talk@rubyforge.org">Facebooker-talk@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/facebooker-talk" target="_blank">http://rubyforge.org/mailman/listinfo/facebooker-talk</a><br>
<br></blockquote></div><br></div>