/** * Check whether iterating over session namespaces works */ public function testIteration() { $ns = new SessionNamespace(); $values = array('key1' => 'val1', 'key2' => 'val2'); $ns->setAll($values); foreach ($ns as $key => $value) { $this->assertEquals($value, $values[$key]); } }
/** * Read all values written to the underling session and make them accessible. */ public function read() { $this->clear(); $this->open(); foreach ($_SESSION as $key => $value) { if (strpos($key, self::NAMESPACE_PREFIX) === 0) { $namespace = new SessionNamespace($this); $namespace->setAll($value); $this->namespaces[substr($key, strlen(self::NAMESPACE_PREFIX))] = $namespace; } else { $this->set($key, $value); } } session_write_close(); $this->hasBeenTouched = true; }