我有一个具有重定向功能的控制器:
public function myControllerMethod() 
{
    $data = $this->blabla();
    return Redirect::to('previousroute')->with('data', $data);
}前面的路由由otherControllerMethod()处理,如下所示:
public function otherControllerMethod()
{
    $data = Session::get('data');
    return $this->makeView($data);
}不幸的是,Laravel忘记了这个会话数据。我以前已经做过很多次了,我从来没有见过在一次重定向后忘记会话闪存数据的情况。这里发生什么事情?我尝试过添加和删除"web“中间件,但都不起作用。如果有人知道为什么会发生这种情况,请告诉我。
发布于 2016-06-24 13:27:42
use Session;
public function myControllerMethod() 
{
    $data = $this->blabla();
    Session::set('data', $data);
    return Redirect::to('previousroute')->with('data', $data);
}
public function otherControllerMethod()
{
    $data = Session::get('data');
    return $this->makeView($data);
}试着这样做。使用会话并在会话中设置数据,然后从您想要的位置获取数据。
https://stackoverflow.com/questions/38001629
复制相似问题