Javascript update for SDK in Javascript browser does not work in Firefox

I am building a website using Facebook Connect and therefore using the Javascript SDK for Facebook. Problem: when using Firefox, the page does not reload properly after logging in or logging out.

FB.Event.subscribe(
   '{% if current_user %}auth.logout{% else %}auth.login{% endif %}',
    function(response){
        window.location.reload();
});

Obviously, this seems like a known issue (just enter โ€œwindow reloadโ€ not working on firefox, and you will get many results)

More precisely, Firefox does not seem to send the correct cookie when the page reloads ...
 - When I click to log in as soon as Facebook registers me and sets a cookie, Firefox does not send a cookie
 - When I log out as soon as Facebook logs out and deletes the cookie, Firefox sends the cookie that was previously there.
In conclusion, I use some "cache functions".

I tried to make a workaround as described here and implemented this:

redirect_url = encodeURIComponent(window.location.href);
url = window.location.href + "account/login?redirect_url=" + redirect_url;
window.location.replace(url);

But the problem remains (cache, I think ...) Can you help me?

Thank.

+5
source share
5 answers

window.location.reload() setTimeout() . -, Firefox cookie. cookie.

+13

, Firefox , setTimeout() . , :

document.location.reload();

:

setTimeout('document.location.reload()',0);

Firefox, , , . , "" JavaScript , script . Chrome IE, Firefox.

+3

window.location.href = url;

window.location.replace(url);

Firefox.

0

, Rails Koala, cookie , :

def fb_authenticate
  @fb_cookies ||= Koala::Facebook::OAuth.new.get_user_info_from_cookie(cookies)
  if @fb_cookies
    #login user or create new user
  else
    redirect_to :controller => 'account', :action => 'fb_authenticate'
  end
end
0

URL :

top.location.href = 'https://apps.facebook.com/YOUR_APP_NAME/?t=' + <?php echo time(); ?>;

PHP, JS (Math.round(+ new Date()/1000), ).

0
source

All Articles