/** * Check if a session with the given key already exists * * @param string $id The session id key. * @param array $data * @return bool */ public function write($id, $data) { if (!\CCFile::write($this->file_path($id), serialize($data))) { \CCError::exception(new Exception('Could not write session file.')); } return true; }
/** * Check if a session with the given key already exists * * @param string $id The session id key. * @param array $data * @return bool */ public function write($id, $data) { $columns = array(); foreach ($this->index_fields as $field) { $columns[$field] = $data[$field]; unset($data[$field]); } $columns['content'] = serialize($data); // When the session id didnt change we will do an update if ($id == $this->inital_session_id) { // because the we might already be in the shutdown process we // have to forward sql error directly to CCError try { \DB::update($this->table, $columns)->where('id', $id)->run($this->database); } catch (\Exception $e) { \CCError::exception($e); } } else { // add the id to the columns $columns['id'] = $id; // because the we might already be in the shutdown process we // have to forward sql error directly to CCError try { \DB::insert($this->table, $columns)->run($this->database); } catch (\Exception $e) { \CCError::exception($e); } } }
// run error shutdown to catch possible errors if (class_exists("\\CCError")) { \CCError::shutdown(); } }); /* *--------------------------------------------------------------- * exception handler *--------------------------------------------------------------- * * Register our handler for uncaught exceptions, so we can * handle them on our own. */ set_exception_handler(function (Exception $exception) { if (class_exists("\\CCError")) { \CCError::exception($exception); } }); /* *--------------------------------------------------------------- * exception handler *--------------------------------------------------------------- * * Register our error handler. */ set_error_handler(function ($level, $message, $file = null, $line = null) { if (class_exists("\\CCError")) { \CCError::error($level, $message, $file, $line); } }); /*