Added functionality to check whether a user is logged in.