Setter $value parameter in JInputCookie is declared as mixed, so it should accept array values, the same as other setters. But currently JInputCookie set method fails do do this is faulty as it tries to do just setcookie($name, $value) - which does not work for arrays. Cookies with array values need to be set for each array value separately with array keys in name - see example 3 here http://php.net/manual/en/function.setcookie.php
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-10-12 20:24:07 |
Closed_By | ⇒ | zero-24 |
Labels |
Added:
?
|
Steps to reproduce the issue
Run this code
JFactory::getApplication()->input->cookie->set("arraytest", array("asssoc1"=>"assoc1value","asssoc2"=>"assoc2value" ),time() + 365 * 86400);
Expected result
Cookies arraytest[asssoc1] with value "assoc1value", and arraytest[asssoc2] with value "assoc2value" beeing set
Actual result
Warning: setcookie() expects parameter 2 to be string, array given in libraries\joomla\input\cookie.php on line 85
No cookie is set