So I'm trying to redirect with a session/flash variable, but I can't seem to figure out why the session variable is never present after the redirect.
I have a controller action like this:
public function verifyAction(Request $request)
{
return redirect()
->route('login')
->with('test', 'Test');
}
and on the login route I'm dumping the session (using Laravel's Session()->all() function), however it never seems to contain the 'test' key.
I'm using 'artisan route:list' to show the routes like this:
+--------+----------+--------+--------+---------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+--------+--------+---------------+------------+
| | GET|HEAD | login | login | @loginAction | web |
| | GET|HEAD | verify | verify | @verifyAction | web |
+--------+----------+--------+--------+---------------+------------+
and both routes are using the web middleware as specified in the docs ([laravel.com/docs][1]) but the session data is always empty after the redirect, like this:
["_flash"]=>
array(2) {
["old"] => array(0) {}
["new"] => array(0) {}
}
I'm expecting to see the 'test' key in the _flash array after the redirect but actually it's always empty. Any ideas what's going on here and how I could get it working?
One thing that strikes me as strange is that I can add normal session variables in the controller like this and it works fine:
Session::put([
'test-2' => 'Testing'
]);
So session variables work fine, it's just flash variables that aren't working.
Distro: Ubuntu 19.04 (Disco Dingo), Laravel 5.8, Laradock, Docker version 18.09.5, build e8ff056, Php 7.2.15.
EDITS
Browser activity:
Request URL: http://localhost/verify?code=ABC&uid=2 Request Method: GET Status Code: 302 Found Remote Address: [::1]:80 Referrer Policy: no-referrer-when-downgrade
Request URL: http://localhost/login Request Method: GET Status Code: 200 OK Remote Address: [::1]:80 Referrer Policy: no-referrer-when-downgrade