![Laravel 5.2 withErrors()失效以及Session::flash()失效解决方法 https://blog.img.crazyphper.com/2017/11/321.jpg](https://blog.img.crazyphper.com/2017/11/321.jpg)
搞了我好2个小时。
同一套Larvel5.2 来来去去做了几套项目都没遇到过这个问题。问题的解决方法如图:
将web的StartSession::class, 和 ShareErrorsFromSession::class, 移入protected $middleware 里,问题解决。
(来源:https://segmentfault.com/q/1010000004209713?_ea=530018)
![Laravel 5.2 withErrors()失效以及Session::flash()失效解决方法 https://blog.img.crazyphper.com/2017/11/change-300x144.jpg](https://blog.img.crazyphper.com/2017/11/change-300x144.jpg)
你的路由不可以将web用到middleware,会引起重复加载Session导致失效的问题。
![Laravel 5.2 withErrors()失效以及Session::flash()失效解决方法 https://blog.img.crazyphper.com/2017/11/333.jpg](https://blog.img.crazyphper.com/2017/11/333.jpg)