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;
}
Please login to continue.