Ad
Flash Session Not Working In Middleware Laravel 5.2
I am newcomer in Laravel. I have a problem with session flash in Middleware. In Middleware:
public function handle($request, Closure $next)
{
if(auth()->check()){
return $next($request);
}else{
Notification::error('Please login');
return redirect()->route('admin.auth.login.get')->with('test',' session');
}
}
In View:
I get Nofitication but nothing happen. I check with flash session (session('test'))-> nothing happen.
Please help to explain me why it dont work? and what's solution?.
Thank you very much and sorry about my English.
Ad
Answer
Add your route in web
middleware
Route::group(['middleware' => ['web']], function () {
//
});
See this
basic-routing
Make sure that in kernel.php
web
Middleware is
'web' => [
\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,
],
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 - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad