Php ';未根据请求设置会话存储';包括标题后
我在handler.php文件中使用以下异常处理程序:Php ';未根据请求设置会话存储';包括标题后,php,laravel,laravel-5,Php,Laravel,Laravel 5,我在handler.php文件中使用以下异常处理程序: public function render($request, Exception $e) { if ($e instanceof CustomException) { return response()->view('errors.404', [], 404); } return parent::render($request, $e); } 在我将标题包含到404.blade.php文
public function render($request, Exception $e)
{
if ($e instanceof CustomException) {
return response()->view('errors.404', [], 404);
}
return parent::render($request, $e);
}
在我将标题包含到404.blade.php
文件之前,它工作正常:
@include('includes.header')
我开始收到此错误:
Session store not set on request. (View: C:\xampp\htdocs\sharp\resources\views\includes\header.blade.php)
由于未找到路由,因此启动会话的
web
中间件从未应用
我不喜欢,但它是相关的
取而代之的是,考虑将参数传递给嵌套的模板,指定是否调用模板调用“代码> Auth::USER())/>代码>,通过<代码> @如果刀片指令。< /P> 比如:
@include('includes.header',['omit_auth'=>true])
然后在标题模板中:
@if(!empty($omit_auth))
{{Auth::user()->name}
@恩迪夫
您的includes.header
模板的内容是什么?您正在访问该模板中的会话吗?是的,我正在使用Auth::user()作为示例。