samedi 18 juin 2016

Laravel 5 won't logout user randomly

In my Laravel 5 app when I try to logout of the session, sometimes the logout only "refresh" the page, I have already tried almost everything.

My logout code is the default one:

public function getLogout()
{
    Auth::logout();
    Session::flush();
    return redirect('/');
}

Could it be the timed ajax request for updating the notifications? The timer runs 10 in 10 sec... I already tried this code to stop all requests when I click in logout:

//Handle logout
$(document).on('click', "#logout", function(event){
    for (var i = 1; i < 99999; i++)
        window.clearInterval(i);
});
$.xhrPool = [];
$.xhrPool.abortAll = function() {
    $(this).each(function(idx, jqXHR) {
        jqXHR.abort();
    });
    $.xhrPool = [];
};

$.ajaxSetup({
    beforeSend: function(jqXHR) {
        $.xhrPool.push(jqXHR);
    },
    complete: function(jqXHR) {
        var index = $.xhrPool.indexOf(jqXHR);
        if (index > -1) {
            $.xhrPool.splice(index, 1);
        }
    }
});

What else can it be?

EDIT:

Ajax timer code:

setInterval(function(){
      $.ajax({
            url: '/notification/update',
            type: 'POST',
            data: {
                last: last
            },
            success: function (response) {
               //does something
            }
    });
},10000);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire