You are here

public function WriteSafeSessionHandler::write in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php \Drupal\Core\Session\WriteSafeSessionHandler::write()

File

core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php, line 83

Class

WriteSafeSessionHandler
Wraps the session handler to prevent writes when not necessary or allowed.

Namespace

Drupal\Core\Session

Code

public function write($session_id, $session_data) {

  // Only write the session when it has been modified.
  if (isset($this->readSessions[$session_id]) && $this->readSessions[$session_id] === $session_data) {
    return TRUE;
  }
  if ($this
    ->isSessionWritable()) {
    return $this->wrappedSessionHandler
      ->write($session_id, $session_data);
  }
  return TRUE;
}