original_string: public function handler_write($sid, $session_data) {
          if ($this->failed) {
              // Do not write anything back - we failed to start the session properly.
              return false;
          }
  
          $sessdata = base64_encode($session_data); // There might be some binary mess :-(
          $hash = sha1($sessdata);
  
          if ($hash === $this->lasthash) {
              return true;
          }
  
          try {
              if ($this->recordid) {
                  $this->database->set_field('sessions', 'sessdata', $sessdata, array('id'=>$this->recordid));
              } else {
                  // This happens in the first request when session record was just created in manager.
                  $this->database->set_field('sessions', 'sessdata', $sessdata, array('sid'=>$sid));
              }
          } catch (\Exception $ex) {
              // Do not rethrow exceptions here, this should not happen.
              error_log('Unknown exception when writing database session data : '.$sid.' - '.$ex->getMessage());
          }
  
          return true;
      }
code: public function handler_write($sid, $session_data) {
          if ($this->failed) {
              // Do not write anything back - we failed to start the session properly.
              return false;
          }
  
          $sessdata = base64_encode($session_data); // There might be some binary mess :-(
          $hash = sha1($sessdata);
  
          if ($hash === $this->lasthash) {
              return true;
          }
  
          try {
              if ($this->recordid) {
                  $this->database->set_field('sessions', 'sessdata', $sessdata, array('id'=>$this->recordid));
              } else {
                  // This happens in the first request when session record was just created in manager.
                  $this->database->set_field('sessions', 'sessdata', $sessdata, array('sid'=>$sid));
              }
          } catch (\Exception $ex) {
              // Do not rethrow exceptions here, this should not happen.
              error_log('Unknown exception when writing database session data : '.$sid.' - '.$ex->getMessage());
          }
  
          return true;
      }
code_tokens: public function handler_write ( $ sid , $ session_data ) { if ( $ this -> failed ) { // Do not write anything back - we failed to start the session properly. return false ; } $ sessdata = base64_encode ( $ session_data ) ; // There might be some binary mess :-( $ hash = sha1 ( $ sessdata ) ; if ( $ hash === $ this -> lasthash ) { return true ; } try { if ( $ this -> recordid ) { $ this -> database -> set_field ( 'sessions' , 'sessdata' , $ sessdata , array ( 'id' => $ this -> recordid ) ) ; } else { // This happens in the first request when session record was just created in manager. $ this -> database -> set_field ( 'sessions' , 'sessdata' , $ sessdata , array ( 'sid' => $ sid ) ) ; } } catch ( \ Exception $ ex ) { // Do not rethrow exceptions here, this should not happen. error_log ( 'Unknown exception when writing database session data : ' . $ sid . ' - ' . $ ex -> getMessage ( ) ) ; } return true ; }
docstring: Write session handler.
  
  {@see http://php.net/manual/en/function.session-set-save-handler.php}
  
  NOTE: Do not write to output or throw any exceptions!
  Hopefully the next page is going to display nice error or it recovers...
  
  @param string $sid
  @param string $session_data
  @return bool success
docstring_tokens: Write session handler .