I\'m trying to get my flash message to display.
This is in my routing file
Route::post(\'users/groups/save\', function(){
return Redirect::to(\'users/g
This works for me
@if(Session::has('success'))
<div class="alert-box success">
<h2>{{ Session::get('success') }}</h2>
</div>
@endif
Laravel 4.2 Personally i use
Session::flash('key', 'value');
return Redirect::to('some/url');
then in the view id first check if there is a session of that key in the view
@if(Session::has('key'))
{{Session::get('key')}} //this prints out the message or your 'value' in the session::flash method
@endif
it works for me most of the time and i usually have that blade template integrated into my view just so i can push success messages to the view from my codes.
please do note that it is stated in the documentation that "Sometimes you may wish to store items in the session only for the next request. You may do so using the Session::flash method" so yes it expires after the next page.
hope this helps
This link describes how to do this http://vegibit.com/flash-messages-in-laravel/
Just tried with laravel 5 - works to me.
i just realized in using the Redirect::to(), when you use the withInput() method, chaining a with() function to pass variables will not work. the only way is either you flash your inputs separately using Input::flash(), and use the with() to pass your variables or you pass your variable via session using Session::flash('key','val') and retrieve in the view via session::get('key').
this should work at localhost and on host and i tried it.
<?php $success = Session::get('success'); ?>
@if($success)
<div class="alert-box success">
<h2>{{ $success }}</h2>
</div>
@endif
Inside of the routes.php file try to create your routes within the
Route::group(['middleware' => ['web']], function () {
//routes here
}
then use
@if(Session::has('success'))
<div class="alert-box success">
<h2>{{ Session::get('success') }}</h2>
</div>
@endif