Reputation: 497
I'm using Laravel 5.8 with custom authentication and because of that, I need to use Cache Tags.
To make it work, my CACHE_DRIVE
is set as array
.
But with this configuration, I can't make flash session messages work when redirect to the view.
In CustomAuthController.php I've tried:
return redirect()
->route('login')
->withErrors('The credentials do not match our records');
OR
return redirect()->route('login')->with('error','The credentials do not match our records');
In login.blade.php results the same:
<?php print '<pre>'; print_r(session()->all()); ?>
Results:
Array
(
[_token] => yyUtSaFx3AxPrJR0biJ5HmjyHU0r5PYY0xi4kLGK
[_previous] => Array
(
[url] => http://127.0.0.1:8001
)
[_flash] => Array (
[old] => Array()
[new] => Array()
)
)
Routes:
Route::group(['middleware' => ['web']], function () {
// Authentication Routes...
Route::get('/', 'Auth\CustomAuthController@showLoginForm');
Route::name('login')->get('login', 'Auth\CustomAuthController@showLoginForm');
Route::name('login')->post('login', 'Auth\CustomAuthController@login');
Route::name('logout')->get('logout', 'Auth\CustomAuthController@logout');
Route::group(['middleware' => ['auth']], function () {
Route::name('home')->any('home', 'HomeController@home');
});
});
Anyone could help please? Thanks in advance!
Upvotes: 2
Views: 7140
Reputation: 3751
Please try-
In CustomAuthController.php:
return redirect()->route('login')->withErrors(['error' => 'The credentials do not match our records']);
In login.blade.php:
<p>{{session('errors')->first('error');}}</p>
Upvotes: 3
Reputation: 29
Try:
return redirect()->route('login')->with(['error' => 'The credentials do not match our records']);
Upvotes: 0