Ad
Laravel Redirect Route With Variable Not Working
I'm using Laravel 5.2 and when I use with
it doesn't flash the data over.
If I use
Session::flash('test', 'test');
Then it shows the session flash data.
If I put the ->with on the index it also doesn't work either.
Controller
public function store(Request $request)
{
return Redirect::route('registration::index')->with('test1', 'test');
}
public function index()
{
return view('registration.index');
}
View:
{{ var_dump(Session::all()) }}
What's going wrong here..?
Ad
Answer
In Laravel 5.2 the StartSession
middleware is no longer added to the global $middleware
list in the App\Http\Kernel
class. Instead it's added to the web
middleware group, so the session doesn't start automatically with a request. You have two options to fix this:
1. Add the routes that need to use the session in a route group that uses the web
middleware group:
Route::group(['middleware' => ['web']], function () {
Route::get('/', '[email protected]');
Route::post('store', '[email protected]');
});
2. Move the middleware from the group to the global middleware list so that the session is started on every request:
protected $middleware = [
...
\Illuminate\Session\Middleware\StartSession::class,
];
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad