You can use either assuming you're running PHP 5.3, however, if you're running anything below that, then use:
$user = JFactory::getUser();
if($user->id!=0){
//your code goes here
}
Personally, I would go for the second method as it goes through the Joomla API and is a tad more thorough.
On a side note, if you do use the first method, you can remove the &
.