如何通过插值或使用条件在 Laravel 5.4 Blade 中显示 Cookie 值?
有点像这样:
@if (Cookie::get('user_first_name') !== null)
<a href="javascript:;" id="user_name">
<i class="fa fa-sign-in" aria-hidden="true"></i>{{ Cookie::get('user_first_name') }}
</a>
@else
最佳答案
您建议的方式是正确的:
{{ Cookie::get('user_first_name') }}
根据您的评论,您可能没有正确设置 cookie。您可以尝试:
Cookie::queue('user_first_name', 'John', 15);
return view('the-view');
关于Laravel 5.4 在 Laravel Blade 中显示 Cookie 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46618576/