简体   繁体   English

Laravel Session数据在视图和控制器上有所不同

[英]Laravel Session data different in views and controllers

In my PagesController I have method view(Page $page) , which gets called by the route: 在我的PagesController我有方法view(Page $page) ,它由路由调用:

Route::get('{page}', 'PagesController@view');

The method body is as follows: 方法主体如下:

public function view(Page $page)
{

    // Process content vars
    $page->content = ContentVarsProcessor::process($page->content);

    var_dump(\Session::get('form_contact-form_response'));

    return $page->out();
}

And the $page->out() body is: $page->out()主体为:

public function out()
{

    // ... some processing

    $content = view($view, $data)->render();

    return $content;
}

Inside the view, I have 在视图内部,我有

{{ var_dump(session('form_'.$form->identifier.'_response')) }}

And the interest thing is that the two dumps show different data.. The data is flashed on form validation, and should be gone after 1 request, but it keeps persisting, while in the controller it's showing null. 有趣的是,这两个转储显示了不同的数据。数据在表单验证时闪烁,应在1个请求后消失,但仍保持不变,而在控制器中则显示为空。 The dumps are as follows: 转储如下:

C:\wamp\www\wsv\app\Modules\Pages\Controllers\PagesController.php:21:null

C:\wamp\www\wsv\storage\framework\views\7dbbca5089cdc8f8c9e49cadafb0bb435b7adf4d.php:7:string '{"status":"error","errors":["Name is required"]}' (length=48)

On the same page, on the same request. 在同一页面上,在同一请求上。 What am I missing here? 我在这里想念什么?

Thanks 谢谢

Same bug as per the other issue - inconsistent middleware included. 与其他问题相同的错误-包含不一致的中间件。

Laravel Flash Data Persisting indefinitely Laravel Flash数据无限期存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM