You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try use Phalcon\Http\Response\Cookies, separate from Phalcon\Http\Response. In my app "Cookies" object can contain cookie, or not. And i do not have way to check, is there exists at least one cookie in it, or not, before try to send it, because class do not provide method for this.
So if there are was not added at least one cookie, on calling send() method appear exception "The argument is not initialized or iterable".
I think that because _cookies variable in class defined without value and stay null if there are no cookie set (if i understand Zephir right). And we try to iterate through it in send() method when _cookies is null
There are few ways to fix that:
Make protected _cookies = []; instead protected _cookies;
Check is _cookies not empty/iterable before try iterate through it
Provide for Phalcon\Http\Response\Cookies class method that allow to check, is there are added cookie (something about isEmpty())
Expected behavior
When there are no cookie set, do nothing
How to reproduce
(newPhalcon\Http\Response\Cookies())->send();
Details
Phalcon version: 3.1.2
PHP Version: 7.1.4
The text was updated successfully, but these errors were encountered:
I try use
Phalcon\Http\Response\Cookies
, separate fromPhalcon\Http\Response
. In my app "Cookies" object can contain cookie, or not. And i do not have way to check, is there exists at least one cookie in it, or not, before try to send it, because class do not provide method for this.So if there are was not added at least one cookie, on calling
send()
method appear exception "The argument is not initialized or iterable".I think that because
_cookies
variable in class defined without value and staynull
if there are no cookie set (if i understand Zephir right). And we try to iterate through it insend()
method when_cookies
isnull
There are few ways to fix that:
protected _cookies = [];
insteadprotected _cookies;
_cookies
not empty/iterable before try iterate through itPhalcon\Http\Response\Cookies
class method that allow to check, is there are added cookie (something aboutisEmpty()
)When there are no cookie set, do nothing
Details
The text was updated successfully, but these errors were encountered: