code: func (sm *Manager) UserSession(ctx context.Context) (*types.UserSession, error) {
  	var mgr mo.SessionManager
  
  	pc := property.DefaultCollector(sm.client)
  	err := pc.RetrieveOne(ctx, sm.Reference(), []string{"currentSession"}, &mgr)
  	if err != nil {
  		// It's OK if we can't retrieve properties because we're not authenticated
  		if f, ok := err.(types.HasFault); ok {
  			switch f.Fault().(type) {
  			case *types.NotAuthenticated:
  				return nil, nil
  			}
  		}
  
  		return nil, err
  	}
  
  	return mgr.CurrentSession, nil
  }
docs: // UserSession retrieves and returns the SessionManager's CurrentSession field.
  // Nil is returned if the session is not authenticated.