如何在laravel 5.4中的会话超时时重定向到路由注销

时间:2017-07-21 08:23:00

标签: php laravel session laravel-5

我希望redirect logout route session timeout laravel 5.4 app\exception\handler.php

我在 if ($e instanceof TokenMismatchException) { return redirect()->route('logout'); }

中尝试此操作
ResourceServerTokenServices

但它仍无效。我该怎么办

1 个答案:

答案 0 :(得分:0)

当会话超时时,您基本上不再登录了。

您是否正在保护您需要使用auth中间件登录的用户的路由?我想你错过了这一步。

如果用户未登录(或超时),auth中间件保护的路由会自动重定向到/login(路由可以更改)。

查看文档的这一部分:https://laravel.com/docs/5.4/authentication#protecting-routes