Laravel 5.2 Session flash not working even with web middleware
<p>I am trying to implement flash messaging using sessions but am unable to do so.</p>

<p>In my controller I have: </p>

<pre><code>public function store(Request $request) {
    session()-&gt;flash('donald', 'duck');
    session()-&gt;put('mickey', 'mouse');
    return redirect()-&gt;action('CustomerController@index')-&gt;with('bugs', 'bunny');
}
</code></pre>

<p>But when I check the session variables in the view, I can only see the values from <code>session()-&gt;put('mickey', 'mouse')</code>.</p>

<p>Session:</p>

<pre><code>{"_token":"F6DoffOFb17B36eEJQruxvPe0ra1CbyJiaooDn3F","_previous":{"url":"http:\/\/localhost\/customers\/create"},"flash":{"old":[],"new":[]},"mickey":"mouse"}
</code></pre>

<p>A lot of people encountered this problem by not having the relevant routes inside the web middleware. I made sure to do this as well but it still wouldn't work.</p>

<p>In routes.php:</p>

<pre><code>Route::group(['middleware' =&gt; ['web']], function () {

    Route::get('/', function () {
        return view('welcome');
    });

    Route::get('/customers', 'CustomerController@index');
    Route::get('/customers/create', 'CustomerController@create');
    Route::post('/customers', 'CustomerController@store');
});
</code></pre>

<p>In Kernel.php:</p>

<pre><code>protected $middlewareGroups = [
    'web' =&gt; [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
    ],

    'api' =&gt; [
        'throttle:60,1',
    ],
];
</code></pre>

<p>Can anyone let me know what I could be doing wrong here? Thanks!</p>