Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. //create new route
  2.  
  3. Route::get('/checkAuth', function() {
  4. })->middleware('auth');
  5.  
  6.  
  7. //add this script to your master layout file
  8. <script>
  9. setInterval(function() {
  10. $.ajax({
  11. 'url': '/checkAuth',
  12. 'success': function (response) {
  13. if (response == true) {
  14.  
  15. }
  16. },
  17. error: function( jqXhr, textStatus, errorThrown ){
  18. if (errorThrown == 'Unauthorized') {
  19. location.reload();
  20. alert("You are logging out because you have logged in from another session!");
  21. }
  22. }
  23. });
  24. }, 1000 * 60 * 1); // will check every minute for Auth
  25. </script>
  26.  
  27. // 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