Regenerates id that represents this storage.
public regenerate ( boolean $destroy = false ) : boolean | ||
$destroy | boolean | Destroy session when regenerating? |
Результат | boolean | True if session regenerated, false if error |
/** * {@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()))); }