Skip to content

Commit

Permalink
Fixing real issue for Ticket #137
Browse files Browse the repository at this point in the history
Reverted changes replacing [ and ] with .
  • Loading branch information
phpnut committed Nov 4, 2009
1 parent 7bead5d commit a1ce9e6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cake/libs/controller/components/cookie.php
Expand Up @@ -215,15 +215,15 @@ function write($key, $value = null, $encrypt = true, $expires = null) {
foreach ($key as $name => $value) {
if (strpos($name, '.') === false) {
$this->__values[$name] = $value;
$this->__write(".$name", $value);
$this->__write("[$name]", $value);

} else {
$names = explode('.', $name, 2);
if (!isset($this->__values[$names[0]])) {
$this->__values[$names[0]] = array();
}
$this->__values[$names[0]] = Set::insert($this->__values[$names[0]], $names[1], $value);
$this->__write("." . implode('.', $names), $value);
$this->__write('[' . implode('][', $names) . ']', $value);
}
}
$this->__encrypted = true;
Expand Down Expand Up @@ -289,12 +289,12 @@ function delete($key) {
}
if (strpos($key, '.') === false) {
unset($this->__values[$key]);
$this->__delete(".$key");
$this->__delete("[$key]");
return;
}
$names = explode('.', $key, 2);
$this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]);
$this->__delete("." . implode('.', $names));
$this->__delete('[' . implode('][', $names) . ']');
}

/**
Expand All @@ -315,11 +315,11 @@ function destroy() {
if (is_array($value)) {
foreach ($value as $key => $val) {
unset($this->__values[$name][$key]);
$this->__delete(".$name.$key");
$this->__delete("[$name][$key]");
}
}
unset($this->__values[$name]);
$this->__delete(".$name");
$this->__delete("[$name]");
}
}

Expand Down Expand Up @@ -354,6 +354,11 @@ function __expire($expires = null) {
return $this->__expires;
}
$this->__reset = $this->__expires;

if ($expires == 0) {
return $this->__expires = 0;
}

if (is_integer($expires) || is_numeric($expires)) {
return $this->__expires = $now + intval($expires);
}
Expand Down

0 comments on commit a1ce9e6

Please sign in to comment.