https://drupal.org/node/1965634

Untested :) But D5 doesn't have user_is_logged_in() function.