/** * Explicitly destroys all session data * * @param string $reason A reason for destroying the session – used by the LoggingAspect * @return void * @throws Exception\SessionNotStartedException * @api */ 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; }