mmangino / facebooker2

A simple facebook connect library for ruby
MIT License
311 stars 93 forks source link

Cookie 'deleted' on redirect #34

Closed zakmandhro closed 13 years ago

zakmandhro commented 13 years ago

In Rails 3, if a controller does redirect_to, the Facebooker2::Rails::Controller#set_fb_cookie sets fbs_[APP_ID] cookie to deleted. To reproduce:

I commented out the line that sets the cookie to 'deleted' and everything seems to work fine - including login, logout, redirect and refresh.

#cookies[fb_cookie_name] = { :value=>value }#, :expires=>expires}

What am I missing?

mmangino commented 13 years ago

Sadly, I don't really understand how or why the cookie is set. It apparently is supposed to follow the practices of the php library, but it sounds like that isn't happening.

I've asked the creators of that code to help look into this issue.

rjlee commented 13 years ago

I have facebooker2 working successfully in this kind of scenario. The problem is that the access_token being passed into the cookie setting routine is empty, which causes the cookie to be set to deleted. This is desired behavior as far as I'm aware (see the code comments above the cookie setting routine). I think the thing to understand is why the access token is nil at some point in the request cycle which is causing the cookie value to be set to deleted.

Could you post up a sample project on github using the instructions above. I tried to recreate your issue using the above but couldn't - it seemed to work for me. Off the top of my head, it could be a few things, depending on browser, facebook app settings or maybe just a bug.

zakmandhro commented 13 years ago

Here it is, the Rails 3 project to reproduce this: https://github.com/zakmandhro/facebooker2_cookie_bug

You'll need to add your own Facebook App keys to facebooker2.yml. The Facebook-side app settings on mine were default. The only thing I added was Site URL under Web Site pointing to root path.

rjlee commented 13 years ago

Ok, I can replicate the problem. I've actually just prepared some fixes that were related to a bug I was seeing in safari which also seem to fix your problem.

The fixes are currently in : https://github.com/rjlee/facebooker2

Try adding this to the Gemfile :

gem 'facebooker2', :git => 'git://github.com/rjlee/facebooker2.git', :ref => '6fe4cbf'

Could you just check this fixes your issue, it seemed to work when I tried it with your sample app.

I'll be pushing these changes upstream tomorrow, all things being well.

zakmandhro commented 13 years ago

Confirmed, your fork + ref listed above fixed the problem. Thanks! Please let me know when pushed upstream and I'll switch back.

mmangino commented 13 years ago

0.9 released to fix this