private function setCookie($key, $val) { $exp = $this->opt['expire'] ? $this->opt['expire'] : 0; if (false === $val || null === $val) { $exp = time() - 3600; } else { if (is_array($val)) { $val = JSONUtil::arrayToJSON($val); } } //else $val = json_encode($val); $this->log[] = "Set cookie: [{$key}]=[{$val}]"; setcookie($key, $val, $exp, $this->opt['path'], $this->opt['domain'], $this->opt['secure']); }
/** Returns a JSON string containing the message data. The format of the contained JSON depends on the $withWrapper parameter. If it is true then the output will look a little something like (but quoted using JSON conventions): {$this->getWrapperName(): { ... other properties ... } } if $withWrapper is false then the outermost container object is omitted. */ public function toJSON($withWrapper = true) { return JSONUtil::arrayToJSON($withWrapper ? array($this->getWrapperName() => $this->fields) : $this->fields); }