本文整理汇总了PHP中Nette\Http\IRequest::getCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP IRequest::getCookie方法的具体用法?PHP IRequest::getCookie怎么用?PHP IRequest::getCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IRequest
的用法示例。
在下文中一共展示了IRequest::getCookie方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Http\IRequest $httpRequest
* @param Http\IResponse $httpResponse
*/
public function __construct(Http\IRequest $httpRequest, Http\IResponse $httpResponse)
{
$this->httpRequest = $httpRequest;
$this->httpResponse = $httpResponse;
if ($this->httpRequest->getQuery(self::SWITCH_PARAM)) {
$this->viewType = $this->httpRequest->getQuery(self::SWITCH_PARAM);
} else {
if ($this->httpRequest->getCookie(self::COOKIE_KEY)) {
$this->viewType = $this->httpRequest->getCookie(self::COOKIE_KEY);
}
}
}
示例2: __construct
/**
* @param \DK\Translator\Loaders\Loader|string $pathOrLoader
* @param \Nette\Http\IRequest $httpRequest
*/
public function __construct($pathOrLoader, IRequest $httpRequest = null)
{
parent::__construct($pathOrLoader);
if ($httpRequest !== null) {
$this->debugMode = (bool) $httpRequest->getCookie(Panel::COOKIE_DEBUG_KEY);
}
}
示例3: getMetadataCookie
/**
* Parses the metadata cookie that our Javascript API set
*
* @return array
*/
protected function getMetadataCookie()
{
$cookieName = $this->config->getMetadataCookieName();
// The cookie value can be wrapped in "-characters so remove them
if (!($cookieValue = trim($this->httpRequest->getCookie($cookieName), '"'))) {
return array();
}
parse_str($cookieValue, $metadata);
array_walk($metadata, function (&$value, &$key) {
$value = urldecode($value);
$key = urldecode($key);
});
return $metadata;
}
示例4: exists
/**
* Does session exists for the current request?
* @return bool
*/
public function exists()
{
return self::$started || $this->request->getCookie($this->getName()) !== NULL;
}
示例5: start
/**
* Starts and initializes session data.
*
* @throws Nette\InvalidStateException
* @return void
*/
public function start()
{
if (self::$started) {
return;
}
$this->configure($this->options);
Nette\Diagnostics\Debugger::tryError();
session_start();
if (Nette\Diagnostics\Debugger::catchError($e) && !session_id()) {
@session_write_close();
// this is needed
throw new Nette\InvalidStateException('session_start(): ' . $e->getMessage(), 0, $e);
}
self::$started = true;
/* structure:
__NF: Counter, BrowserKey, Data, Meta, Time
DATA: section->variable = data
META: section->variable = Timestamp, Browser, Version
*/
unset($_SESSION['__NT'], $_SESSION['__NS'], $_SESSION['__NM']);
// old unused structures
// initialize structures
$nf =& $_SESSION['__NF'];
if (empty($nf)) {
// new session
$nf = array('C' => 0);
} else {
$nf['C']++;
}
// session regenerate every 30 minutes
$nfTime =& $nf['Time'];
$time = time();
if ($time - $nfTime > self::REGENERATE_INTERVAL) {
$this->regenerated = $this->regenerated || isset($nfTime);
$nfTime = $time;
}
// browser closing detection
$browserKey = $this->request->getCookie('nette-browser');
if (!$browserKey) {
$browserKey = Nette\Utils\Strings::random();
}
$browserClosed = !isset($nf['B']) || $nf['B'] !== $browserKey;
$nf['B'] = $browserKey;
// resend cookie
$this->sendCookie();
// process meta metadata
if (isset($nf['META'])) {
$now = time();
// expire section variables
foreach ($nf['META'] as $section => $metadata) {
if (is_array($metadata)) {
foreach ($metadata as $variable => $value) {
if (!empty($value['B']) && $browserClosed || !empty($value['T']) && $now > $value['T'] || isset($nf['DATA'][$section][$variable]) && is_object($nf['DATA'][$section][$variable]) && (isset($value['V']) ? $value['V'] : null) != Nette\Reflection\ClassType::from($nf['DATA'][$section][$variable])->getAnnotation('serializationVersion')) {
if ($variable === '') {
// expire whole section
unset($nf['META'][$section], $nf['DATA'][$section]);
continue 2;
}
unset($nf['META'][$section][$variable], $nf['DATA'][$section][$variable]);
}
}
}
}
}
if ($this->regenerated) {
$this->regenerated = false;
$this->regenerateId();
}
register_shutdown_function(array($this, 'clean'));
}
示例6: getCookie
/**
* @inheritdoc
*/
public function getCookie($key, $default = NULL)
{
return $this->current->getCookie($key, $default);
}
示例7: beforeRender
public function beforeRender()
{
$this->template->cssLoaderFile = $this->cssLoaderFile;
$this->template->jsLoaderFile = $this->jsLoaderFile;
$this->template->fullcss = $this->httpRequest->getCookie('fullcss');
}