本文整理汇总了PHP中Nette\Http\IResponse::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP IResponse::setCookie方法的具体用法?PHP IResponse::setCookie怎么用?PHP IResponse::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IResponse
的用法示例。
在下文中一共展示了IResponse::setCookie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendCookie
/**
* Sends the session cookies.
* @return void
*/
private function sendCookie()
{
if (!headers_sent() && ob_get_level() && ob_get_length()) {
trigger_error('Possible problem: you are starting session while already having some data in output buffer. This may not work if the outputted data grows. Try starting the session earlier.', E_USER_NOTICE);
}
$cookie = $this->getCookieParameters();
$this->response->setCookie(session_name(), session_id(), $cookie['lifetime'] ? $cookie['lifetime'] + time() : 0, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly'])->setCookie('nette-browser', $_SESSION['__NF']['B'], Response::BROWSER, $cookie['path'], $cookie['domain']);
}
示例2: createCookie
/**
* Gets the cookie
*
* @param string $cookieValue
*/
protected function createCookie($cookieValue)
{
$currentDate = new \DateTime('+1 month');
// Create cookie object
$cookie = new Cookie(self::COOKIE_KEY, $cookieValue, $currentDate->format('Y-m-d'));
// Store cookie in response
$this->httpResponse->setCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
}
示例3: sendCookie
/**
* Sends the session cookies.
* @return void
*/
private function sendCookie()
{
$cookie = $this->getCookieParams();
$this->response->setCookie(
session_name(), session_id(),
$cookie['lifetime'] ? $cookie['lifetime'] + time() : 0,
$cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']
)->setCookie(
'nette-browser', $_SESSION['__NF']['B'],
Response::BROWSER, $cookie['path'], $cookie['domain']
);
}
示例4: sendCookie
/**
* Sends the session cookies.
* @return void
*/
private function sendCookie()
{
$cookie = $this->getCookieParameters();
$this->response->setCookie(session_name(), session_id(), $cookie['lifetime'] ? $cookie['lifetime'] + time() : 0, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
}