Skip to content

khagesh007/laravel-session-resume

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

laravel-session-resume

This is a simple solution to Laravel web session expired when user is not intracting with page. This will check if user session is active if its not active it will send a csrf token from controller which can be used on expired page for login form otherwise It wouldn't work, After successful login it will close the login modal and all the tokens on current page forms will be updated to latest one. //write code block

$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status == 401 || xhr.status == 419){
        checkSession();
    }
});

This will check for ajax error code 401 & 419 and run session checker then will show modal to the user. You can add other xhr response code here as you wish, I am using this approch to not run the session checker on background for like every minute or so.

About

This is a working code of a Laravel session checker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published