Reputation: 1015
I want to show username into top right side of my header in my laravel webpage but the value isn't shown.
After login successfully I have set the username
into Session
but the value doesn't show. No error shown also!
Controller
Session::put('user_id', $data->id);
Session::put('user_name', $data->name);
Session::put('user_email', $data->email);
return redirect('/home');
In blade
{{ Session::get('name') }}
How to solve that? Where is the problem? Anybody help please?
Upvotes: 2
Views: 1941
Reputation: 35190
Going off the code in your question, you're looking for name
but you haven't stored a value with name
. I'm assuming it should be user_name
. Try changing your code to be:
{{ Session::get('user_name') }}
Upvotes: 1
Reputation:
You should use the name user_name
instead of name
in your view
{{ Session::get('user_name') }}
Upvotes: 1
Reputation: 1814
You should use the same name.. In controller you assigned value to another variable..
Session::put('user_id', $data->id);
Session::put('user_name', $data->name);
Session::put('user_email', $data->email);
So use that variables in your view.
{{Session::get('user_id')}}
{{Session::get('user_name')}}
{{Session::get('user_email')}}
Upvotes: 2