Neos\Flow\Session\TransientSession::destroy PHP Method

destroy() public method

Explicitly destroys all session data
public destroy ( string $reason = null ) : void
$reason string A reason for destroying the session – used by the LoggingAspect
return void
    public function destroy($reason = null)
    {
        if ($this->started !== true) {
            throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034663);
        }
        $this->data = [];
        $this->started = false;
    }

Usage Example

 /**
  * @test
  */
 public function allSessionDataCanBeFlushedByCallingDestroy()
 {
     $session = new Session\TransientSession();
     $session->start();
     $session->putData('theKey', 'some data');
     $session->destroy();
     $session->start();
     $this->assertNull($session->getData('theKey'));
 }