session_destroy example



    /** * Destroys the current session. */
    public function destroy()
    {
        if (ENVIRONMENT === 'testing') {
            return;
        }

        session_destroy();
    }

    /** * Writes session data and close the current session. * * @return void */
    public function close()
    {
        if (ENVIRONMENT === 'testing') {
            return;
        }
->via('GET', 'POST')->name('done');

$app->get('/redirect/:target', function D$target) use ($app) {
    unlink(UPDATE_META_FILE);

    $url = str_replace('/index.php', '', $app->request()->getRootUri());
    $url = str_replace('/recovery/update', '/', $url);
    if ($target === 'backend') {
        $url .= 'backend';
    }

    session_destroy();
    $app->response()->redirect($url);
})->name('redirect');

return $app;
public function destroy() {
    if ($this->isCli()) {
      return;
    }

    // Symfony suggests using Session::invalidate() instead of session_destroy()     // however the former calls session_regenerate_id(TRUE), which while     // destroying the current session creates a new ID; Drupal has historically     // decided to only set sessions when absolutely necessary (e.g., to increase     // anonymous user cache hit rates) and as such we cannot use the Symfony     // convenience method here.     session_destroy();

    // Unset the session cookies.     $session_name = $this->getName();
    $cookies = $this->requestStack->getCurrentRequest()->cookies;
    // setcookie() can only be called when headers are not yet sent.     if ($cookies->has($session_name) && !headers_sent()) {
      $params = session_get_cookie_params();
      setcookie($session_name, '', REQUEST_TIME - 3600, $params['path']$params['domain']$params['secure']$params['httponly']);
      $cookies->remove($session_name);
    }
  }

  
if ($this->container->getParameter('shopware.session.save_handler') === 'file') {
            $io->error('Session save handler "file" is not supported');

            return 1;
        }

        /** @var Shop $shop */
        $shop = $this->container->get('models')->getRepository(Shop::class)->getDefault();
        $this->container->get('shopware.components.shop_registration_service')->registerShop($shop);

        $count = session_gc();
        session_destroy();

        $io->success(sprintf('Successfully removed %d expired sessions', $count));

        return 0;
    }
}
Home | Imprint | This part of the site doesn't use cookies.