Nette\Http\Session::destroy PHP Method

destroy() public method

Destroys all data registered to a session.
public destroy ( ) : void
return void
    public function destroy()
    {
        if (!self::$started) {
            throw new Nette\InvalidStateException('Session is not started.');
        }
        session_destroy();
        $_SESSION = NULL;
        self::$started = FALSE;
        if (!$this->response->isSent()) {
            $params = session_get_cookie_params();
            $this->response->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
        }
    }

Usage Example

Example #1
0
 public function success(Form $form)
 {
     $values = $form->getValues();
     if ($values['section'] === 'all') {
         $this->cacheStorage->clean(array(Cache::ALL => true));
         $this->session->destroy();
     } elseif ($values['section'] === 'cache') {
         $this->cacheStorage->clean(array(array(Cache::ALL => true)));
     } elseif ($values['section'] === 'sessions') {
         $this->session->destroy();
     }
 }
All Usage Examples Of Nette\Http\Session::destroy