/** * Session write handler. * Do not call this method directly. * @param string $id session ID * @param string $data session data * @return boolean whether session write is successful */ public function writeSession($id, $data) { if ($this->dbSession) { return $this->dbSession->writeSession($id, $data); } else { parent::writeSession($id, $data); } }
/** * @depends testReadWrite */ public function testWriteCustomField() { $session = new DbSession(); $session->writeCallback = function ($session) { return ['user_id' => 15]; }; $session->writeSession('test', 'session data'); $query = new Query(); $sessionRow = $query->from('session')->where(['id' => 'test'])->one(); $this->assertEquals('session data', $sessionRow['data']); $this->assertEquals(15, $sessionRow['user_id']); }