author:咔咔

使用withCookie来添加响应

Route::get('testCookie',function(){
$content = 'Hello LaravelAcademy!';
$status = 200;
$value = 'text/html;charset=utf-8';
return response($content,$status)->header('Content-Type',$value)
->withCookie('site','LaravelAcademy.org');
});

【laravel】把cookie添加到响应_laravel

第二种方式:

Route::get('testCookie',function(){
$minutes = 24 * 60;
return response('欢迎来到 Laravel 学院')->cookie('name', '学院君', $minutes);
});

【laravel】把cookie添加到响应_html_02