Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5.8重定向,错误为不显示消息_Php_Laravel_Caching_Laravel 5.8 - Fatal编程技术网

Php Laravel 5.8重定向,错误为不显示消息

Php Laravel 5.8重定向,错误为不显示消息,php,laravel,caching,laravel-5.8,Php,Laravel,Caching,Laravel 5.8,我使用带有自定义身份验证的Laravel5.8,因此,我需要使用缓存标记。 为了使其正常工作,我的缓存\u驱动器设置为阵列 但是使用这种配置,当重定向到视图时,我无法使flash会话消息工作 在CustomAuthController.php中,我尝试了: return redirect() ->route('login') ->withErrors('The credentials do not match our records'); OR ret

我使用带有自定义身份验证的Laravel5.8,因此,我需要使用缓存标记。 为了使其正常工作,我的
缓存\u驱动器
设置为
阵列

但是使用这种配置,当重定向到视图时,我无法使flash会话消息工作

在CustomAuthController.php中,我尝试了:

return redirect()
       ->route('login')
       ->withErrors('The credentials do not match our records');

OR

return redirect()->route('login')->with('error','The credentials do not match our records');

在login.blade.php中,结果相同:

<?php print '<pre>'; print_r(session()->all()); ?>
路线:

return redirect()->route('login')->with(['error' => 'The credentials do not match our records']);
有人能帮忙吗? 提前谢谢

试试看:

return redirect()->route('login')->withErrors(['error' => 'The credentials do not match our records']);
请试一试-

CustomAuthController.php中:

<p>{{session('errors')->first('error');}}</p>
在login.blade.php中:

<p>{{session('errors')->first('error');}}</p>
{{session('errors')->first('error');}


请检查您是否在所有涉及的路由中都有web中间件组,否则您可能会错过StartSession中间件。@dparoli我用路由更新了我的问题我收到了此错误
未定义变量:错误(视图:/var/www/html/gobrax fleetmoney/resources/views/login.blade.php)
我更新了答案。请尝试让我知道它是否有效。谢谢@Rashed Hasan!
<p>{{session('errors')->first('error');}}</p>