* * 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:----k90b108qvPXWcRkABTPSN/B8XAepficf8wxYyK4Zc+o7mwO43tsEsIz82vsJ9QRNODnJeoeDRt4JOteYQ5E99o9rffyflBWp2rCqzL48slHvfIXOvkyzIRGYoiZKZobn9TYRRfWvsCnkkqCpIakqT7bKlTFX9QbkSL47+J9UJalwRUkLyD8dOwA7ANT/FJmjcw77o4sFRhE+pt9p4pOt5v/MMLXQPNu8edbfDu5+IKoz/FJYLtbM04hdvZBSywBvF+4nDzUy11GnO/+42X+Lf1xcb2sBnuvHHstLyzitGhmJeqkKFOBilKSJDgG0ow0VU3oOMlBKGXVdueOwvt7sFJPACwxi4ge1w12nTN+yIj5S3AQ7l3Hto+iV3xdnimvKkoNOr17aCbi8H4kx7RDTSWBU52Z1IsMpp1qBaCrK1ftzMcccP+ZomH/RzJQbBIXRQnZOnkCQ+2NujIHMMXA9ae4ghBFQM32tiv0WuaK7FuGqYLc2j4a7qMtXQNfYyls5fg6NOTO3+6VE06/VG1YjJd7tiuuxRkov85GRetudMD6IHswe9zKvDHd9+VA9OdgHnhAhqADKxl2XKnz4yJSm1DW+pUM43jywuvbWF05OEXzba5anJe7XFuC96PgDsvzHvs2FItRvEiz3VxxvBOIiIZBtXdCWneJpFpx/Gca+r48=----ATTACHMENT:----NTY5MTE2NTYxOTg2NzA4NiA5MDIxMjc2MTc4NTU3NDUzIDUyMzEzNzcxMzQ5MTkyOTg=