[英]Passing cookie from controller to view in laravel
I have problem with getting cookie which I saved earlier. 我在获取之前保存的cookie时遇到问题。 I want to pass it through controller to view. 我想将其通过控制器进行查看。 Here is my cookie saved in jQuery (it works, checked). 这是我保存在jQuery中的cookie(有效,已选中)。
$('.wybierz').on('click',function(){
var id = $(this).attr('name');
Cookies.set('chosenComp', id);
highlightChoice(id);
});
and here is my controller 这是我的控制器
public function index(Request $request){
$cookie = Cookie::get('chosenComp');
$actualComp = $cookie;
$coms = DB::table('items')->get();
$teams = DB::table('results')->get();
return view('nowa_druzyna',['teams'=>$teams],['coms'=>$coms])->with('actualComp',$actualComp);
}
First of all I just wanted to try passing the cookie which is a number but it doesn't show. 首先,我只想尝试传递cookie,它是一个数字,但没有显示。 My view 我的观点
<option selected class="showCurrentComp" id="">{{$actualComp}}</option>
Javascript存储原始cookie,Laravel希望对cookie进行加密,您可以从EncryptCookies中间件中免除cookie
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.