I was wondering how to do a global variable to save me few lines of copy and pasting this lines. Array it probably and put them in one variable instead? I want to use this
You should create an object to do that.
Create a provider
object with those properties, email
, name
, etc and instantiate it and set the properties values, like:
$provider = new Provider();
$provider->email = Auth::user()->email;
And then you save the object in your session:
$_SESSION['provider'] = $provider;
I'm not familiar with Laravel and I don't know if it's a good practice to work directly with the Auth
object but a simpler solution would be:
$_SESSION['provider'] = Auth::user();
Also be aware of working with sensitive information on your session :)