Laravel 5.4在Laravel刀片中显示cookie值
如何通过插值或使用条件在laravel 5.4 blade中显示cookie值 有点像这样:Laravel 5.4在Laravel刀片中显示cookie值,laravel,cookies,laravel-5.4,Laravel,Cookies,Laravel 5.4,如何通过插值或使用条件在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')
@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
@if(Cookie::get('user\u first\u name')!==null)
@否则
您建议的方式是正确的:
{{ Cookie::get('user_first_name') }}
根据您的评论,您可能没有正确设置cookie。你可以尝试:
Cookie::queue('user_first_name', 'John', 15);
return view('the-view');
您是否尝试过:
{{cookie('user\u first\u name')}
?我在使用您的代码时收到此消息:user\u first\u name=deleted;expires=2016年10月7日星期五09:26:58 GMT;最大年龄=-31536001;路径=/;httponly