0
votes

I have a simple success message on store to DB.

\Session::flash('info', 'Success! Words created');

now if I var_dump the session and return that, great.

As soon as I move to another view. Session info is gone!

I've tried all sorts, I'm on laravel 5.1.

looked into the middleware groups but i just get blank pages when adding routes in here..

1
This question is little unclear to me. Can you more elaborate? - smartrahat
I have a controller with a store method which after persisting adds a flash message above. When redirecting to a view I cannot access the session message. If I dump the session object in the method I can see my message. Soon as it goes to the view, session message is gone. - VineFreeman
Sorry my version is 5.2.* so I assume it's to do with sessions but I cannot get it to work - VineFreeman
Please, share view code for display Session message. And route.php too. - smartrahat

1 Answers

2
votes

This is a breaking problem with the 5.2 upgrade. What's happening is the middleware which is responsible for making that errors variable available to all your views is not being utilized because it was moved from the global middleware to the web middleware group.

There are two ways to fix this:

  1. In your kernel.php file(app/Http/Kernel.php), you can move the middleware \Illuminate\View\Middleware\ShareErrorsFromSession::class back to the protected $middleware property.

  2. Wrap all your web routes with a route group and apply the web middleware to them:

    Route::group(['middleware' => 'web'], function() {
        // Place all your web routes here...(Cut all `Route` which are define in `Route file`, paste here) 
    });