Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to set cookie value to array #8073

Closed
klas opened this issue Oct 12, 2015 · 2 comments · Fixed by #8081
Closed

Impossible to set cookie value to array #8073

klas opened this issue Oct 12, 2015 · 2 comments · Fixed by #8081

Comments

@klas
Copy link
Contributor

klas commented Oct 12, 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

@klas
Copy link
Contributor Author

klas commented Oct 12, 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

@zero-24
Copy link
Contributor

zero-24 commented Oct 12, 2015

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

@zero-24 zero-24 closed this as completed Oct 12, 2015
Kubik-Rubik added a commit that referenced this issue Oct 24, 2015
Fix JInputCookie setter to work with arrays (fixes #8073 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants