duanqinqian5299 2016-02-16 09:25
浏览 243

在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.

  • 写回答

1条回答 默认 最新

  • doumu9799 2016-02-16 13:04
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度