code: func (c *ServerContext) CreateOrJoinSession(reg *SessionRegistry) error {
  	// As SSH conversation progresses, at some point a session will be created and
  	// its ID will be added to the environment
  	ssid, found := c.GetEnv(sshutils.SessionEnvVar)
  	if !found {
  		return nil
  	}
  	// make sure whatever session is requested is a valid session
  	_, err := rsession.ParseID(ssid)
  	if err != nil {
  		return trace.BadParameter("invalid session id")
  	}
  
  	findSession := func() (*session, bool) {
  		reg.Lock()
  		defer reg.Unlock()
  		return reg.findSession(rsession.ID(ssid))
  	}
  
  	// update ctx with a session ID
  	c.session, _ = findSession()
  	if c.session == nil {
  		log.Debugf("Will create new session for SSH connection %v.", c.Conn.RemoteAddr())
  	} else {
  		log.Debugf("Will join session %v for SSH connection %v.", c.session, c.Conn.RemoteAddr())
  	}
  
  	return nil
  }
docs: // CreateOrJoinSession will look in the SessionRegistry for the session ID. If
  // no session is found, a new one is created. If one is found, it is returned.