cookie操作
<?php namespace appcontrollers; use yiiwebController; use yiiwebCookie; class HelloController extends Controller{ //存入cookie和修改cookie $cookies = YII::$app->response->cookies; $cookie_data = array('name'=>"user","value"=>"zhangsan"); $cookies->add(new Cookie($cookie_data));//以'cookieValidationKey' 为基础的加密字符串 $cookies->remove("id");//移除掉ID的cookie //取出cookie的值 $cookies = YII::$app->request->cookies; $cookies->getValue("user"); //如果cookie不存在 $cookies->getValue("user",20);//返回20 } ?>