PHP Ver | 5.6.27 |
CakePHP Ver | 3.1.9 |
cakephp3 Cookieを使う
・App/Controller/AppController.php
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Cookie'); ←この行を追記
}
$this->Cookie->config([
'expires' => '+10 days',
'path' => '/',
'domain' => 'localhost',
'secure' => true,
'key' => 'Security.salt',
'httpOnly' => true,
'encryption' => 'aes'
]);
※詳細については http://book.cakephp.org/3.0/en/controllers/components/cookie.html 参照
$this->Cookie->write('cookie_name', 'info');
$this->Cookie->read('cookie_name');
$this->Cookie->delete('cookie_name');
0 件のコメント:
コメントを投稿