Want to know if the person that's viewing your custom block is authenticated? Need to change the elements visible on the page based on a user's permissions or roles? Want to display a welcome message for users returning to your site?
All of these things require knowing who the user is that's currently accessing a page. This can be accomplished by using the 'current_user' service to load an object that contains information about the current user. As well as methods for checking permissions, and retrieving additional information.
In this tutorial we'll: