Yii2学习笔记三:Cookies操作
1.添加修改cookies
$cookie=array("name"=>"user","value"=>"demo1","expire"=>24*3600,‘httpOnly' => true,); Yii::$app->response->cookies->add(new Cookie($cookie));
2.删除cookies
Yii::$app->response->cookies->remove("user");
3.获取cookies
Yii::$app->response->cookies->get('user'); Yii::$app->request->cookies->getValue('user');
4.判断cookies
if($cookies->has('language')) if(isset($cookies['language']))
5.其他
$lifetime = $this->rememberMe ? 24*3600 : 0; session_set_cookie_params($lifetime); ip2long(Yii::$app->request->userIP)
下一篇:Yii2学习笔记四:视图之数据块
文章
总共 0 条评论