UserAuthenticationController::loginStatus

public UserAuthenticationController::loginStatus()

Checks whether a user is logged in or not.

Return value

\Symfony\Component\HttpFoundation\Response The response.

File

core/modules/user/src/Controller/UserAuthenticationController.php, line 257

Class

UserAuthenticationController
Provides controllers for login, login status and logout via HTTP requests.

Namespace

Drupal\user\Controller

Code

public function loginStatus() {
  if ($this->currentUser()->isAuthenticated()) {
    $response = new Response(self::LOGGED_IN);
  }
  else {
    $response = new Response(self::LOGGED_OUT);
  }
  $response->headers->set('Content-Type', 'text/plain');
  return $response;
}
doc_Drupal
2016-10-29 09:52:18
Comments
Leave a Comment

Please login to continue.