public function getLifeTime() { $stores = Mage::app()->getStores(); if (empty($stores)) { return self::SEESION_MAX_COOKIE_LIFETIME; } else { return parent::getLifeTime(); } }
/** * @return int|mixed */ public function getLifeTime() { if (!$this->_config) { return parent::getLifeTime(); } if ($this->_lifeTime === NULL) { $lifeTime = NULL; // Detect bots by user agent $botLifetime = (int) ($this->_config->descend('bot_lifetime') ?: self::DEFAULT_BOT_LIFETIME); if ($botLifetime) { $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? FALSE : $_SERVER['HTTP_USER_AGENT']; $isBot = !$userAgent || preg_match(self::BOT_REGEX, $userAgent); if ($isBot) { if ($this->_logLevel > Zend_Log::DEBUG) { $this->_log(sprintf("Bot detected for user agent: %s", $userAgent)); } if ($this->_sessionWrites <= 1 && ($botFirstLifetime = (int) ($this->_config->descend('bot_first_lifetime') ?: self::DEFAULT_BOT_FIRST_LIFETIME))) { $lifeTime = $botFirstLifetime * (1 + $this->_sessionWrites); } else { $lifeTime = min(parent::getLifeTime(), $botLifetime); } } } // Use different lifetime for first write if ($lifeTime === NULL && $this->_sessionWrites <= 1) { $firstLifetime = (int) ($this->_config->descend('first_lifetime') ?: self::DEFAULT_FIRST_LIFETIME); if ($firstLifetime) { $lifeTime = $firstLifetime * (1 + $this->_sessionWrites); } } // Neither bot nor first write if ($lifeTime === NULL) { $lifeTime = parent::getLifeTime(); } $this->_lifeTime = $lifeTime; if ($this->_lifeTime < $this->_minLifetime) { $this->_lifeTime = $this->_minLifetime; } if ($this->_lifeTime > $this->_maxLifetime) { $this->_lifeTime = $this->_maxLifetime; } } return $this->_lifeTime; }
/** * @return int|mixed */ public function getLifeTime() { if ($this->_isBot) { return min(parent::getLifeTime(), $this->_botLifetime); } return parent::getLifeTime(); }