yii2 如何批量添加多个cookie? [ 2.0 版本 ]
官网的例子如下:
// get the cookie collection (yii\web\CookieCollection) from the "response" component
$cookies = Yii::$app->response->cookies;
// add a new cookie to the response to be sent
$cookies->add(new \yii\web\Cookie([
'name' => 'language',
'value' => 'zh-CN',
]));
但问题是我有一个数组,如何可以快速批量添加?是否支持:
// get the cookie collection (yii\web\CookieCollection) from the "response" component
$cookies = Yii::$app->response->cookies;
// add a new cookie to the response to be sent
$cookies->add(new \yii\web\Cookie([
'k1' => 'v1',
'k2' => 'v2',
'k3' => 'v3',
]));
共 2 个回答
phptest
注册时间:2014-06-08
最后登录:2018-12-03
在线时长:9小时54分
最后登录:2018-12-03
在线时长:9小时54分
- 粉丝5
- 金钱118
- 威望0
- 积分208