Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //create new route
- Route::get('/checkAuth', function() {
- })->middleware('auth');
- //add this script to your master layout file
- <script>
- setInterval(function() {
- $.ajax({
- 'url': '/checkAuth',
- 'success': function (response) {
- if (response == true) {
- }
- },
- error: function( jqXhr, textStatus, errorThrown ){
- if (errorThrown == 'Unauthorized') {
- location.reload();
- alert("You are logging out because you have logged in from another session!");
- }
- }
- });
- }, 1000 * 60 * 1); // will check every minute for Auth
- </script>
- // that is all, every page will have the script embeded and will run every minute to check if logged in. If not the page will refresh forcing a login then return you back to the page you were at
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement