public function get_description() { $buf = new StringBuf(); $buf->add($this->value); if ($this->expires !== null) { if (ufront_web_HttpCookie::$tzOffset === null) { ufront_web_HttpCookie::$tzOffset = intval(date('Z', $this->expires->__t)); } $gmtExpires = Date::fromTime($this->expires->getTime() + ufront_web_HttpCookie::$tzOffset); $zeroPad = array(new _hx_lambda(array(&$buf, &$gmtExpires), "ufront_web_HttpCookie_0"), 'execute'); $day = ufront_web_HttpCookie::$dayNames[$gmtExpires->getDay()]; $date = call_user_func_array($zeroPad, array($gmtExpires->getDate())); $month = ufront_web_HttpCookie::$monthNames[$gmtExpires->getMonth()]; $year = $gmtExpires->getFullYear(); $hour = call_user_func_array($zeroPad, array($gmtExpires->getHours())); $minute = call_user_func_array($zeroPad, array($gmtExpires->getMinutes())); $second = call_user_func_array($zeroPad, array($gmtExpires->getSeconds())); $dateStr = "" . _hx_string_or_null($day) . ", " . _hx_string_or_null($date) . "-" . _hx_string_or_null($month) . "-" . _hx_string_rec($year, "") . " " . _hx_string_or_null($hour) . ":" . _hx_string_or_null($minute) . ":" . _hx_string_or_null($second) . " GMT"; ufront_web_HttpCookie::addPair($buf, "expires", $dateStr, null); } ufront_web_HttpCookie::addPair($buf, "domain", $this->domain, null); ufront_web_HttpCookie::addPair($buf, "path", $this->path, null); if ($this->secure) { ufront_web_HttpCookie::addPair($buf, "secure", null, true); } return $buf->b; }
public function setCookie($id, $expiryLength) { $expireAt = null; if ($expiryLength <= 0) { $expireAt = null; } else { $d = Date::now(); $expireAt = Date::fromTime($d->getTime() + 1000.0 * $expiryLength); } $path = "/"; $domain = null; $secure = false; $sessionCookie = new ufront_web_HttpCookie($this->sessionName, $id, $expireAt, $domain, $path, $secure, null); if ($expiryLength < 0) { $sessionCookie->expireNow(); } $this->context->response->setCookie($sessionCookie); }