只要进行了AJAX POST,Laravel 4 app就会将用户注销

时间:2015-07-29 15:27:19

标签: php jquery ajax laravel laravel-4

我有一个关于Laravel 4问题的噩梦。

任何时候,每次在应用程序中对服务器进行AJAX POST时,它都会立即记录系统用户!这很糟糕,无法调试ti似乎

有没有人对解决方案有任何想法?

以下是正在制作AJAX请求的一些示例......

$.ajax({
    type: 'post',
    url: '/orders/orderboards/order/add-item-comment',
    data: 'order_item_id=' + order_item_id+'&name='+name+'&body='+body+'&user_id='+user_id,
    success: function(result) {
      if(result.success){
        console.log('SUCCESS AJAX Comment created: ');


        working = false;
        $(result.html).hide().insertBefore('#addCommentContainer').slideDown();
        $('#body').val('');

      }else{
        console.log('FAILURE AJAX did not save comment:');
      }

    }
});

我还在我的应用程序的某些字段上使用了jQuery库X-Editable,它将字段转换为适当的编辑,并且它也处理这些帖子的所有AJAX方面。

我可以使用AJAX请求来加载数据而不会出现问题,只是在创建或更新您注销的数据时才会发生。

更新

似乎无论何时向服务器发出AJAX请求,它都会重置laravel_session cookie值。我不确定会导致这种情况。

我在过去注意到如果打开配置调试选项,那么每个请求也会重置此值并将您注销。似乎AJAX请求也会使这种行为发生=(

解决方案的任何想法?

1 个答案:

答案 0 :(得分:0)

This was a very super strange issue which I still do not know the reasoning for it however I do know the cause now...

My JavaScript app made an AJAX request to build the content of a Modal window. In this generated HTML, it made a request to get a Gravatar image and when the image was not a correct URL to a real gravatar image, it forced my user to be instantly logged out of my Laravel 4 app.

I have no idea why that would do anything my my server. Would love to hear some reasoning?