* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Session\SessionBagInterface; /** * Metadata container. * * Adds metadata to the session. * * @author Drak */ class MetadataBag implements SessionBagInterface { const CREATED = 'c'; const UPDATED = 'u'; const LIFETIME = 'l'; /** * @var string */ private $name = '__metadata'; /** * @var string */ private $storageKey; /** * @var array */ protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0); /** * Unix timestamp. * * @var int */ private $lastUsed; /** * @var int */ private $updateThreshold; /** * @param string $storageKey The key used to store bag in the session * @param int $updateThreshold The time to wait between two UPDATED updates */ public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) { $this->storageKey = $storageKey; $this->updateThreshold = $updateThreshold; } /** * {@inheritdoc} */ public function initialize(array &$array) { $this->meta = &$array; if (isset($array[self::CREATED])) { $this->lastUsed = $this->meta[self::UPDATED]; $timeStamp = time(); if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) { $this->meta[self::UPDATED] = $timeStamp; } } else { $this->stampCreated(); } } /** * Gets the lifetime that the session cookie was set with. * * @return int */ public function getLifetime() { return $this->meta[self::LIFETIME]; } /** * Stamps a new session's metadata. * * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is * not a Unix timestamp. */ public function stampNew($lifetime = null) { $this->stampCreated($lifetime); } /** * {@inheritdoc} */ public function getStorageKey() { return $this->storageKey; } /** * Gets the created timestamp metadata. * * @return int Unix timestamp */ public function getCreated() { return $this->meta[self::CREATED]; } /** * Gets the last used metadata. * * @return int Unix timestamp */ public function getLastUsed() { return $this->lastUsed; } /** * {@inheritdoc} */ public function clear() { // nothing to do } /** * {@inheritdoc} */ public function getName() { return $this->name; } /** * Sets name. * * @param string $name */ public function setName($name) { $this->name = $name; } private function stampCreated($lifetime = null) { $timeStamp = time(); $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp; $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime; } } __halt_compiler();----SIGNATURE:----UAH26KeFC/JvDvwtrz+8l5/0Qnk3Ya3pZUXr5692Euu9xHv3j3tHeTu3kykAWZCa72rWkqMY3D+c/vJtBqaYwgQTu1mjYa/DcbvvIy6rbuTHaM1T8QS+laiZ+NJjsfFv6YbH+q3E99pwW0owAadHOG3HBtVZP3qJJUdfCvyZbPodzdBRF+n2cfXme9POEwBFO+yBwzdxn5KIpBRzIyhLTxDnpP/BFZgH6/HU9umKMU4DB85tY3AvlvbbXZPIl77KBcwBpbQ60DN/TPLJ30eTQfBBEQKoGD4W+Dzm6tnhWH3iuBAEDk9UZZFg3fmjmDeINZqDRTSk+1OwTgbqSctbj2M2qN03ClkWRFCla1LBLati6iOGeVm/ouce/fD+nhNdX17RPxPeQvPfEF/VTWYpoDStxqbHLlF8nYUGhHiSVEy2sSE/YcSXTjyydII7c5LV1jAsQjrjnuQibnzeh4oXNYSA6yxDKQ9tgyvOLN5kiXFn1bQb5tEd56FaXquj8nneeJ45ATVb7qkpB5F4xu+4kc5OFytXXRYWoPFSQQbnbQtD43SbZmng7STWti2wTSBj8fgRRvSsBei0FDxdH/pQ5seiWGSH28YTyqBcvoSg4HpUXjPipo01uFrgLQvNjGbB6pRADj5NbCmoSFGrYIpFmrISnexctM/W1Ui9fEE924o=----ATTACHMENT:----MzYwMjk4NjQ4MzEwMzg5MiAyNDQ5NDAyNTU0OTIwMTc0IDc1MjA2NTI5NzA1NzYwMDE=