Phalcon\Session\Adapter\Aerospike::destroy PHP Method

destroy() public method

public destroy ( string $sessionId = null ) : boolean
$sessionId string Session variable name [Optional]
return boolean
    public function destroy($sessionId = null)
    {
        if (null === $sessionId) {
            $sessionId = $this->getId();
        }
        if (!isset($_SESSION) || !is_array($_SESSION)) {
            $_SESSION = [];
        }
        foreach ($_SESSION as $id => $key) {
            unset($_SESSION[$id]);
        }
        return $this->db->delete($sessionId);
    }

Usage Example

Example #1
0
 public function testShouldDestroySession()
 {
     $sessionId = 'abcdef123457';
     $session = new SessionHandler($this->getConfig());
     $data = serialize(['abc' => 345, 'def' => ['foo' => 'bar'], 'zyx' => 'xyz']);
     $this->tester->haveInAerospike($sessionId, base64_encode($data));
     $session->destroy($sessionId);
     $this->tester->dontSeeInAerospike($sessionId);
 }