Yii2 provides wrong cookies data -


executing:

var_dump(yii::$app->request->cookies); var_dump($_cookie); 

provides different result:

in first case:

object(yii\web\cookiecollection)[60]   public 'readonly' => boolean true   private '_cookies' =>      array (size=1)       '_csrf' =>          object(yii\web\cookie)[63]           public 'name' => string '_csrf' (length=5)           public 'value' => string '9uu8ofwtuhsqvms_nxp3jyavb-sonnhz' (length=32)           public 'domain' => string '' (length=0)           public 'expire' => null           public 'path' => string '/' (length=1)           public 'secure' => boolean false           public 'httponly' => boolean true 

in second:

array (size=10)       '__utma' => string '123' (length=3)       '__utmc' => string '123' (length=3)       '__utmz' => string '123' (length=3)       'id' => string '16532' (length=5)       'name' => string 'xxx' (length=3)       'pwd' => string '8804c3c7b0d0addbecfaa2755946d5b6' (length=32)       'access_token' => string 'xxx' (length=3)       '_csrf' => string 'efc99e00558359ef396179424ff81f59b4197ec00b8ac84341eb13cbf06b3674a:2:{i:0;s:5:"_csrf";i:1;s:32:"9uu8ofwtuhsqvms_nxp3jyavb-sonnhz";}' (length=130) 

why cookies data different?

cookies accessed though yii::$app->request->cookies subject cookie validation turned on default.

to not break compatibility 3rd parties $_cookie remains untouched.

read more here: http://www.yiiframework.com/doc-2.0/guide-runtime-sessions-cookies.html#cookie-validation


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -