I think ad_get_user_id returns zero for a non logged in user. Use this:
ad_get_user_id
set user_id [ad_get_user_id] if {[string match "0" ${user_id}]} { # do something } else { # do something else }