Added check to make sure the PHP session ID is valid