How to check if user logged in or not?

Hi! Does anyone know how to track and modify content based on if the user is logged in or not? Even in Javascript? What shell we look for and where? Also how to add additional custom implementation of the basic user and memberships? Any documentation or other? For now for instance what I am trying to do is to check if the user is already logged in direct to a separate page. How to do that?