writeSession() public method

Do not call this method directly.
public writeSession ( string $id, string $data ) : boolean
$id string session ID
$data string session data
return boolean whether session write is successful
示例#1
0
文件: Session.php 项目: Liv1020/cms
 /**
  * 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);
     }
 }
示例#2
0
 /**
  * @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']);
 }