?
Referenced as Pull Request for: # 8081
avatar klas
klas
12 Oct 2015

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

avatar klas klas - open - 12 Oct 2015
avatar klas
klas - comment - 12 Oct 2015

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

avatar zero-24 zero-24 - close - 12 Oct 2015
avatar zero-24
zero-24 - comment - 12 Oct 2015

Closing as we have a PR. I'm going to copy your instructions. Thanks. #8081

avatar zero-24 zero-24 - change - 12 Oct 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-10-12 20:24:07
Closed_By zero-24
avatar zero-24 zero-24 - close - 12 Oct 2015
avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment