How do I determine if a user session is currently logged in or not?

I'm want to write something like ...

Code:
if ( user is logged in ) {
    // display log out link
} else {
   // display log in link
}
I know how to display the log in link, but do not know how to write the condition in the if statement. Also I have not figured out what is the logout link yet.

Thanks in advanced.