dqrnskni67375 2016-01-16 09:59
浏览 81
已采纳

Laravel 5.2 - Session ::无法正常工作

I want to display an 'falsh-message' for the user I start to redirect him in the routes.php with following code :

Route::get('/alert',function () {
    return redirect()->route('home')->with('message', 'This is a Test Message!');
});

In the alerts.blade.php that I include in the home view I would like to read this message with:

Route::group(['middleware' => ['web']], function () {
  Route::get('/alert',function () {
        return redirect()->route('home')->with('message', 'This is a Test Message!');
    });
});

My Session would be set under storage\framework\sessions with the following code :

a:5:{s:6:"_token";s:40:"8304u3fjR9EhvA88QMVGQnGcgdUcWoZj9LrHaDPh";s:7:"message";s:23:"This is a Test Message!";s:5:"flash";a:2:{s:3:"new";a:0:{}s:3:"old";a:1:{i:0;s:7:"message";}}s:9:"_previous";a:1:{s:3:"url";s:22:"http://localhost/alert";}s:9:"_sf2_meta";a:3:{s:1:"u";i:1452937821;s:1:"c";i:1452937821;s:1:"l";s:1:"0";}}

But the Problem is that Laravel gives me no output from the message because it is empty. So maybe someone can help me.

routes.php :

Route::group(['middleware' => ['web']], function () {
    Route::get('/', [
        'uses' => '\App\Http\Controllers\HomeController@index',
        'as' => 'home',
    ]);
    Route::get('/alert',function () {
        return redirect()->route('home')->with('message', 'This is a Test Message!');
    });
});
  • 写回答

4条回答 默认 最新

  • dpleylxzx47207117 2016-01-16 15:14
    关注

    Insert session flash data explicitly..

    Route::get('/alert',function () {
        $request->session()->flash('message', 'Task was successful!');
        return redirect()->route('home');
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器