This is how we can tell if there is no session in the GeneXus Access Manager or if the session that exists is anonymous.
It is valid both for Auto-Register Anonymous Users and for knowing if the session is anonymous in web applications (Anonymous Sessions in GAM - Web Applications).
&GAMSession = GAMSession.Get(&GAMErrors) //&GAMErrors is a GAMError collection data type, &GAMSession type is GAMSession
This is how we can find out if the SD application has an auto-registered user:
Auto-register anonymous user - SD usage example