Handling expired token in Laravel

后端 未结 13 2788
情话喂你
情话喂你 2020-11-29 00:30

What is the best way to handle expired tokens in laravel 5.

I mean I have a page and it has some links which perform ajax requests. They work fine when the page is

13条回答
  •  臣服心动
    2020-11-29 01:06

    a short and fast way.... for handling ajax requests,when token expire : add this script to the end of master layout or your document

    $(window).load(function(){
        $.ajaxSetup({
            statusCode: {
                419: function(){
                        location.reload(); 
                    }
            }
        });
    });
    

    and for handling http requests when token expires, create 419.blade.php in this path: \resources\views\errors and add this script to it:

    
    

提交回复
热议问题