cakephp的cookie是作为一个插件封装了php的cookie操作。
var $components= array('Cookie');
//设置cookie的基本信息
function beforeFilter() {
$this->Cookie->name = 'baker_id';名字
$this->Cookie->time = 3600; // or '1 hour'过期时间可以是字符
$this->Cookie->path = '/bakers/preferences/'; 保存路径
$this->Cookie->domain = 'example.com'; 域
$this->Cookie->secure = true; //i.e. only sent if using secure HTTPS $this->Cookie->key = 'qSI232qs*&sXOw!';随机密码
}
关于cookie基本的方法:
$this->Cookie->write('user',array('name'=>'swing','rolw'=>'admin'));
可以存储单个或多个值
$this->Cookie->read('user');读取cookie的值
$this->Cookie->delete('user');删除cookie
destory();销毁当前cookie