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?
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')}}
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') }}
您应该在视图中使用名称user_name
而不是name
{{ Session::get('user_name') }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.