Neos\Flow\Session\Session::destroy PHP Метод

destroy() публичный Метод

Explicitly destroys all session data
public destroy ( string $reason = null ) : void
$reason string A reason for destroying the session – used by the LoggingAspect
Результат void
    public function destroy($reason = null)
    {
        if ($this->started !== true) {
            throw new Exception\SessionNotStartedException('Tried to destroy a session which has not been started yet.', 1351162668);
        }
        if ($this->remote !== true) {
            if (!$this->response->hasCookie($this->sessionCookieName)) {
                $this->response->setCookie($this->sessionCookie);
            }
            $this->sessionCookie->expire();
        }
        $this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
        $this->storageCache->flushByTag($this->storageIdentifier);
        $this->started = false;
        $this->sessionIdentifier = null;
        $this->storageIdentifier = null;
        $this->tags = [];
        $this->request = null;
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Session\Exception\SessionNotStartedException
  */
 public function destroyThrowsExceptionIfSessionIsNotStarted()
 {
     $session = new Session();
     $session->destroy();
 }