Ali Shaukat
Ali Shaukat

Reputation: 965

Redirect to specific route on session timeout in laravel 5

In the session.php file under Config directory of laravel 5.1, I have specified 'lifetime' => 10 which logout the user after 10 minutes of inactivity. But it does not redirect to login page automatically when the session expires until the user clicks on some link.

I want to redirect the user to the login page instantly after the session expire even if no link is clicked. I also want to get some values in the session before resetting it.

Upvotes: 1

Views: 1500

Answers (1)

Raymond Cheng
Raymond Cheng

Reputation: 2505

you need use javascript to achieve this,

when the first time you set session,in that page

var t_click=0;
var timer= function(){
setTimeout('timer()', 1000);
    t_click += 1;
    if(t_click <= 600){
        window.location.href="the page url you want go and deal with what you want to do";
    }
}

above is the javascript after 10 minites will trigger redirect

Upvotes: 0

Related Questions