Handling expired token in Laravel

后端 未结 13 2794
情话喂你
情话喂你 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:22

    a work around for it, is to actually get the new token every certain time, otherwise you are defeating the purpose of the csrf token:

    
        
            
        
        
            
        
    
    

    In laravel routes

    Route::get('refresh-csrf', function(){
        return csrf_token();
    });
    

    I apologize in case of any syntax errors, haven't used jquery for long time, but i guess you get the idea

提交回复
热议问题