You’re going to want to use the is_user_logged_in()
conditional tag to handle this.
global $current_user;
get_currentuserinfo();
if ( is_user_logged_in() ) {
echo "<span>Welcome $current_user->user_login</span>".
"<a href="".wp_logout_url()."">Logout</a>";
} else {
echo '<a href="#">Login</a>';
}
Other functions referenced: wp_logout_url() & get_currentuserinfo()
FYI, all of this could easily be found on Google or in the WordPress Codex.