Simplified the test for session existence in the database.