Sign up ×

I have this script that I put on the head section of my html:

    function goLogIn(){
        alert("go login");
        window.location.href = "{{ path('_security_check') }}";

    function onFbInit() {
        if (typeof(FB) != 'undefined' && FB != null ) {
            FB.Event.subscribe('auth.statusChange', function(response) {
                if (response.session || response.authResponse) {
                    setTimeout(goLogIn, 500);
                } else {
                    window.location.href = "{{ path('_security_logout') }}";

So the alert box here is printed out. However I tried logging in and logging out, but none of the login or logout is triggered. Any idea why?

Here's how I initialized the facebook button:

<!-- inside a twig template -->
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}

{{ facebook_login_button({'autologoutlink': true, 'label': 'Log in using Facebook'}) }}
share|improve this question
Is "{{ path('_security_logout') }}" being interpolated by Twig? –  pdoherty926 Sep 15 '12 at 4:59
@ethagnawl mind clarifying what interpolated mean? the thing is that it didn't even print the alert, either login or logout –  xonegirlz Sep 15 '12 at 5:05
Does Twig turn {{ path('_security_logout') }} into a string? Are there any errors in the console? Have you tried placing an alert inside the 'auth.statusChange' callback, but outside the if? –  pdoherty926 Sep 15 '12 at 5:10
@ethagnawl yes and it didn't print the alert as well –  xonegirlz Sep 15 '12 at 5:12
What is the value of FB inside onFbInit? Have you included the facebook.js script on the page? –  pdoherty926 Sep 15 '12 at 5:15

1 Answer 1

up vote 0 down vote accepted

It turns out that I have to clear the cookies and then it worked.

share|improve this answer

Your Answer


