How to get current user details ( id, name, email, display name, roles, access time) in Drupal 8/9

In Drupal 8 and Drupal 9, get current user details ( id, name, email, display name, roles, access time) by using the following snippet.
copy-icon

Comments

Authors

Read Next