mmangino / facebooker2

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

Cookie domain #44

Closed vergult closed 12 years ago

vergult commented 13 years ago

Hi there,

I'm working with facebooker2 gem to integrate Open Graph in a webapp which is highly using subdomains. Therefore, I filled up the "site domain" of my facebook app configuration in order to have a persistent cookie on top domain and its subdomains. When logging in, everything works great, but I have encountered issues when logging out a user from the top domain or a subdomain. What happens is the following: if I log out a user from the top domain, the facebook cookie is still present on subdomains and when I log out a user from a subdomain, the cookie is still present on the top domain. Although I configured the domain cookie in my rails app, the problem still persists. I figured out reading facebooker2 code, that when I explicitly set the cookie domain in the "set_fb_cookie" method in "controller.rb" (when it exists of course), it fixes my problem. I think I am/will not be the only one to encounter this issue so decided to contribute.

I have also added a delete_fb_cookie! method to facilitate the cookie destruction when logging out for eg. Indeed, I find it more logical to find such a method in facebooker2 rather than outside of it. Does this breaks the logic of your gem?

Oh and BTW this is my first pull request, hope I can help. Thanks for your great job on mogli and facebooker2!

4nkh commented 13 years ago

It will be great for me...i got the same problem and i quick fixed it like that

function crushCookie(name,value, days) { var domain = "" var expires = "; expires=Thu, 01-Jan-1970 00:00:01 GMT" document.cookie = name+"="+value+expires+"; path=/"+"; domain="+domain; } window.onload=crushCookie("fbs_XXXXXXXXXXX", "delete");

akshayrawat commented 13 years ago

Developing a Canvas app. Have the exact the same problem. + 1 for the pull request.

rtdp commented 13 years ago

I also faced similer issue with facebooker2 and multidomain application.

My fix was this -

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

rather than

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

Which worked well without doing anything else anywhere.

snaggled commented 13 years ago

+1 on the rtdp fix:

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

mmangino commented 13 years ago

Episko, any thoughts on the rtdp fix? I'm way out of the loop on this one but want to get one of these fixes in. In general, I would prefer the simpler fix. Also, whatever I pull in needs to have tests.

vergult commented 13 years ago

Ok with rtdp's fix too.

mmangino commented 12 years ago

Is this still an issue? If so, can somebody re-create a pull request against recent code?