問題描述
我運(yùn)行了 php artisan make:auth 命令,然后我會(huì)一步步解釋我接下來要做什么來理解場景,
I run the php artisan make:auth command and I will explain step by step what I do after that to understand the scenario,
- 登錄新會(huì)話 (example.com/home)
- 打開一個(gè)新標(biāo)簽并粘貼網(wǎng)址,即 example.com/home.
- 現(xiàn)在 2 個(gè)標(biāo)簽頁在同一個(gè)會(huì)話中打開.
- 我從其中一個(gè)選項(xiàng)卡中單擊了注銷,它運(yùn)行良好
- 然后,當(dāng)我嘗試從另一個(gè)選項(xiàng)卡注銷時(shí),它給我一個(gè)錯(cuò)誤消息,提示419 頁面已過期",即使重新加載后它也無處可去.
問題是,這種情況可能會(huì)出現(xiàn),我不想看到這個(gè)錯(cuò)誤信息,點(diǎn)擊注銷后直接注銷,即使會(huì)話已過期.
The thing is, these kind of scenarios may arise, and I don't want to see this error message, just logout after clicking logout, even if the session is expired.
注意:這個(gè)問題不是因?yàn)闆]有添加@csrf
推薦答案
嗯,這是一個(gè)明顯的信息,您可以嘗試為該頁面制作更好的布局,但仍然最好顯示它以便用戶知道發(fā)生了什么.如果您想以不同的方式處理它,您可以嘗試重定向到登錄頁面.
Well that's an obvious message you can maybe try to make a better layout for that page, but still it is good to show it so the user knows what happened. If you want to handle it differently you can try to redirect to the login page.
因此在您的 appExceptionsHandler.php
文件中的 render 方法中添加:
So in your appExceptionsHandler.php
file within the render method add this:
if ($exception instanceof IlluminateSessionTokenMismatchException) {
return redirect()->route('login');
}
這篇關(guān)于Laravel 5.8 顯示“419 頁面已過期"從已清除的會(huì)話中單擊注銷后的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!