Added the function to check if the user is logged in and a function to log the user out