A starting point would be to look at phpBB2/includes/session.php

note: ANONYMOUS is defined as -1 in phpBB2/includes/constants.php as well as in the phpbb_users table