Skip to content
Snippets Groups Projects
Commit 7c5ddecc authored by Demian Katz's avatar Demian Katz
Browse files

Fixed incorrect array handling in cookie container.

parent 23d376be
Branches
Tags
No related merge requests found
...@@ -94,8 +94,12 @@ class Container ...@@ -94,8 +94,12 @@ class Container
{ {
$_COOKIE[$this->groupName . $var] = $value; $_COOKIE[$this->groupName . $var] = $value;
if (is_array($value)) { if (is_array($value)) {
$i = 0;
foreach ($value as $curr) { foreach ($value as $curr) {
setcookie($this->groupName . $var . '[]', $curr, null, '/'); setcookie(
$this->groupName . $var . '[' . $i . ']', $curr, null, '/'
);
$i++;
} }
} else { } else {
setcookie($this->groupName . $var, $value, null, '/'); setcookie($this->groupName . $var, $value, null, '/');
...@@ -125,7 +129,19 @@ class Container ...@@ -125,7 +129,19 @@ class Container
*/ */
public function __unset($var) public function __unset($var)
{ {
$isArray = is_array($_COOKIE[$this->groupName . $var]);
if ($isArray) {
$count = count($_COOKIE[$this->groupName . $var]);
}
unset($_COOKIE[$this->groupName . $var]); unset($_COOKIE[$this->groupName . $var]);
setcookie($this->groupName . $var, '', time() - 3600, '/'); if ($isArray) {
for ($i = 0; $i < $count; $i++) {
setcookie(
$this->groupName . $var . '[' . $i . ']', '', time() - 3600, '/'
);
}
} else {
setcookie($this->groupName . $var, '', time() - 3600, '/');
}
} }
} }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment