not completely.
If you want to perform one of three different actions (not logged in, normal user, admin user), then you must test these states and write logic for each state.
You can store the access level in the session instead of requesting it from the database every time.