예제 #1
0
 /**
  * Update session
  *
  * @param string $sessId
  * @param string $sessData
  * @return boolean
  */
 public function write($sessId, $sessData)
 {
     $bindValues = array('session_id' => $sessId);
     $select = $this->_write->select()->from($this->_sessionTable)->where('session_id = :session_id');
     $exists = $this->_read->fetchOne($select, $bindValues);
     $bind = array('session_expires' => time(), 'session_data' => $sessData);
     if ($exists) {
         $this->_write->update($this->_sessionTable, $bind, array('session_id=?' => $sessId));
     } else {
         $bind['session_id'] = $sessId;
         $this->_write->insert($this->_sessionTable, $bind);
     }
     return true;
 }
예제 #2
0
 /**
  * Update session
  *
  * @param string $sessionId
  * @param string $sessionData
  * @return boolean
  */
 public function write($sessionId, $sessionData)
 {
     // need to use write connection to get the most fresh DB sessions
     $bindValues = array('session_id' => $sessionId);
     $select = $this->_write->select()->from($this->_sessionTable)->where('session_id = :session_id');
     $exists = $this->_write->fetchOne($select, $bindValues);
     // encode session serialized data to prevent insertion of incorrect symbols
     $sessionData = base64_encode($sessionData);
     $bind = array('session_expires' => time(), 'session_data' => $sessionData);
     if ($exists) {
         $this->_write->update($this->_sessionTable, $bind, array('session_id=?' => $sessionId));
     } else {
         $bind['session_id'] = $sessionId;
         $this->_write->insert($this->_sessionTable, $bind);
     }
     return true;
 }