Yes it is certainly a very valid method and used frequently. Even in your menu items you’ll frequently see checks against Yii::app()->user->isGuest used in the ‘visibility’ param.
Other options if you really want to get it out of the view file:
Have a view for logged in and a view for guest and do the check in the controller before calling the first view. Depends on how important it is for you to keep that logic out of the view. Either way you’re going to end up pulling in a partial file for consistency.
Have a ‘add comment’ widget and put the check inside the widget so that it only renders content if the check is passed.