The other thing that catches people out is that session changes are only saved if you explicitly call save() or the request cycle completes so that the terminable middleware runs. If the execution hits dd() or crashes then the session will not be changed.
Jan 12, 2019
3
Level 75
Session array basic usage
Some folks new to Laravel have questions about session array's.
This is just a basic example of usage. And I like the facade better, so add the use statement:
use Illuminate\Support\Facades\Session;
Suppose you wanted to store a companies name and phone, you would:
Session::push('company.name', 'Acme Widgets');
Session::push('company.phone', '915-999-9999');
And somewhere in the app you needed the phone:
echo Session::get('company.phone.0');
// use blade or php as desired
Again just a very basic example.
Please or to participate in this conversation.