Laravel Session Flash persists for 2 requests

The following seems to be available from version 5.1 onward. It used to be undocumented, now it is: see Laravel's session documentation.

session()->now()

This is the same as flash, except it won't persist to the next request.


You are Flashing session data and creating a view instead of redirecting, meaning the message will Flash for this request and for the next one, showing twice.

If you want to show the message on the current request without redirecting, I would suggest providing the errors to your View::make instead of trying to Flash the messages. If you MUST Flash the message on the current request, then you will need to Session::forget('key') or Session::flush() after your view.


As @Drew said earlier

You are Flashing session data and creating a view instead of redirecting, meaning the message will Flash for this request and for the next one, showing twice.

An easy way to flash a message once when you are creating a view is:

Session::flash($key, $value);
Session::push('flash.old', $key);

Happy coding!


I had a similar problem, but I couldn't use Return::redirct, as I was using Ajax to to post to and from a within a set of Tabs.

Therefore, I was calling

Input::flashExcept('_token'); 

only if the validation failed and returning a view with the old input. Assuming validation passed and I wanted to run some functions and create a new view based on new data, I would call:

Session::forget('_old_input');  

I would put this before my final View::make

Hope this helps (or makes sense)...