/** * {@inheritdoc} */ public function switchTo(AccountInterface $account) { // Prevent session information from being saved and push previous account. if (!isset($this->originalSessionSaving)) { // Ensure that only the first session saving status is saved. $this->originalSessionSaving = $this->writeSafeHandler->isSessionWritable(); } $this->writeSafeHandler->setSessionWritable(FALSE); array_push($this->accountStack, $this->currentUser->getAccount()); $this->currentUser->setAccount($account); return $this; }
/** * {@inheritdoc} */ public function delete($uid) { // Nothing to do if we are not allowed to change the session. if (!$this->writeSafeHandler->isSessionWritable() || $this->isCli()) { return; } $this->connection->delete('sessions')->condition('uid', $uid)->execute(); }