Note that you can also add it in your application.rb<div><br></div><div><div>rescue_from Facebooker::Session::SessionExpired, :with => :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"><<a href="mailto:adeel@proletariandesign.com">adeel@proletariandesign.com</a>></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"><<a href="mailto:klochner@gmail.com" target="_blank">klochner@gmail.com</a>></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'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., <%= <a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a> %></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's not catching the exception... must be some other config I have wrong. Odd.<br>
<br>module Facebooker<br> module Rails<br> module Controller<br> include Facebooker::Rails::ProfilePublisherExtensions<br> def self.included(controller)<br> controller.extend(ClassMethods)<br> controller.before_filter :set_adapter<br>
controller.before_filter :set_fbml_format<br> controller.helper_attr :facebook_session_parameters<br> controller.helper_method :request_comes_from_facebook?<br> controller.rescue_from Facebooker::Session::SessionExpired, :with => :facebook_session_expired <br>
end<br><br> def facebook_session_expired<br> clear_fb_cookies!<br> clear_facebook_session_information<br> flash[:error] = "Your facebook session has expired."<br> redirect_to root_url<br>
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"><<a href="mailto:klochner@gmail.com" target="_blank">klochner@gmail.com</a>></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'm using a rescue. I tried advancing this discussion a couple weeks ago - the problem is that to really *know* that the session is valid, you have to try using it (i.e., hit the facebook rest server with a request). 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> module Rails</div><div> module Controller</div><div> def self.included(controller)</div>
<div> controller.rescue_from Facebooker::Session::SessionExpired, :with => :facebook_session_expired </div><div> end</div><div> </div><div> def facebook_session_expired</div><div> clear_fb_cookies!</div>
<div> clear_facebook_session_information</div><div> flash[:error] = "Your facebook session has expired."</div><div> redirect_to root_url</div><div> 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> - 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'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> 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: <%= fb_login_button%><br>8: <br>9: <% if facebook_session %><br>10: <h2>You are logged in as <%= <a href="http://facebook_session.user.name" target="_blank">facebook_session.user.name</a> %></h2><br>
11: <% else %><br>12: <h2>You are not logged in!</h2><br>13: <% 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></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>