LoginSignup
3
3

More than 5 years have passed since last update.

foo.barのようなクッキー名を使うときは、$encryptはtrueで

Posted at

環境

PHP: 5.3.3(CentOS)
CakePHP: 2.4.10

ドット記法

クッキー名にドット記法が使えますが、クッキーをwriteするとき、$encrypt = falseで書き込むと、readができなくなります。

cookie.php
$this->Cookie->write('foo.bar', 'hoge', false);

$hoge = $this->Cookie->read('foo.bar');

: Argument 1 passed to Hash::insert() must be an array, string given, called in /cakephp/lib/Cake/Controller/Component/CookieComponent.php on line 247 and defined [
Hash::get() - CORE/Cake/Utility/Hash.php, line 43
CookieComponent::read() - CORE/Cake/Controller/Component/CookieComponent.php, line 286

Cookie::readメソッドをみると、encryptされていることが必須か、_decryptメソッドでencryptされていないときの考慮がないように見えます。

ドット記法を使わなければ、問題はありませんし、とりあえず、$encrypt=trueで書き込んでおけば、問題はなさそうです。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3