/** * Starts the session. */ public function start() { if (self::$sessionStarted) { return; } // use this object as the session handler session_set_save_handler(array($this, 'sessionOpen'), array($this, 'sessionClose'), array($this, 'sessionRead'), array($this, 'sessionWrite'), array($this, 'sessionDestroy'), array($this, 'sessionGC')); parent::start(); }
/** * {@inheritdoc} */ public function regenerate($destroy = false) { $this->db->del($this->getHashKey()); return parent::regenerate($destroy); }
/** * Regenerates the session ID * Also updates our Mongo record for the existing ID * * @param bool $destroy * @return bool */ public function regenerate($destroy = false) { $existingID = $this->getId(); $collection = $this->options['collection']; $id_field = $this->options['id_field']; $time_field = $this->options['time_field']; $collection = $this->db->selectCollection($collection); $existingSession = $collection->findOne(array($id_field => $existingID)); parent::regenerate($destroy); $newID = $this->getId(); if ($destroy) { // Wipe existing session $collection->remove(array($id_field => $existingID)); } // Seems to be we can only update by specifying a non-updating // field to search by - use the original Mongo ID to do this. return $collection->update(array("_id" => $existingSession["_id"]), array('$set' => array($id_field => $newID, $time_field => new \MongoDate()))); }