eZ\Publish\Core\REST\Server\Controller\SessionController::deleteSessionAction PHP Method

deleteSessionAction() public method

Deletes given session.
public deleteSessionAction ( string $sessionId, Request $request ) : DeletedUserSession
$sessionId string
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\DeletedUserSession
    public function deleteSessionAction($sessionId, Request $request)
    {
        /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
        $session = $request->getSession();
        if (!$session->isStarted() || $session->getId() != $sessionId || !$this->hasStoredCsrfToken()) {
            $response = $this->authenticator->logout($request);
            $response->setStatusCode(404);
            return $response;
        }
        $this->checkCsrfToken($request);
        return new Values\DeletedUserSession($this->authenticator->logout($request));
    }

Usage Example

Beispiel #1
0
 /**
  * Deletes given session.
  *
  * @param string $sessionId
  *
  * @return Values\DeletedUserSession|\Symfony\Component\HttpFoundation\Response
  *
  * @throws \eZ\Publish\Core\Base\Exceptions\UnauthorizedException If the CSRF token is missing or invalid.
  * @throws RestNotFoundException
  *
  * @deprecated Deprecated since 6.5. Use SessionController::refreshSessionAction().
  */
 public function deleteSession($sessionId, Request $request)
 {
     @trigger_error(E_USER_DEPRECATED, 'The session actions from the User controller are deprecated since 6.5. Use the SessionController instead.');
     return $this->sessionController->deleteSessionAction($sessionId, $request);
 }